ID:2104725
 
Code:


Problem description:
So I have two icons for my dashing and its after effect. Theres the dashing effect its self(like wind blowing back behind the player), and a dash trail.
i've already tried several different codes and etc, but i can't seem to get what i want. basically i want my dashing to be like this

 photo 9ff4fa6ff6129f23b21305d6f593597f_large_zps0h4ofqim.gif

Can someone please help out with a demo or something?
Just like this actually, the dash effect and trail is the same icon style.
This is as simple as tracking distance traveled and generating a trail for every x movements.

Show the code you are working with.
No you don't, you want your dashing to look like this:
Lol yes, Ishuri. & What he said
In response to FKI
mob/var
Dashing = 0

obj/var/Owner

obj/Effect/Dash
icon = 'effectdash.dmi'
icon_state = "animate"
pixel_x = -16
pixel_y = -24

New()
var/obj/Effect/Dash_Circles/C = new(src)

obj/Effect/Dash_Circles
icon = 'effectdashtrail.dmi'
icon_state = "animate"
pixel_x = -40
pixel_y = -40

New()
..()

mob
proc
Dash_Effect(location)
var/obj/d1 = new/obj/Effect/Dash
d1.layer = src.layer+1
d1.Owner = src
d1.name = "[src] Dashed"
d1.dir = src.dir
d1.loc = location
d1.alpha=100
spawn(8) del(d1)


mob
var tmp/dashing = FALSE

proc/Dash()
// I'm not sure if you intended this or not.
if(dashing)return

dashing = TRUE
walk(src,src.dir)
for(var/i in 1 to 13)
Dash_Effect(loc)
spawn(8)
walk(usr,0)
sleep world.tick_lag
dashing = FALSE


mob/var/frozen = 0
mob/Move()
if(src.dead) return
if(!src.frozen)
if(src.movement_run)
src.icon_state="Sprint"
else
src.icon_state = ""
if(dashing)
src.icon_state = "Dash"
var/obj/Effect/Dash_Circles/C = new(src)
else
src.icon_state = ""
..()
else
return


Different methods but not really what i want. I was hoping for a whole new set of codes, or demo or something
In response to Mf2
Mf2 wrote:
plz write my code

fixed for you
Lol basically honestly. There's a certain way i want it and i can't get it. been so long and all so...I do require some help, but i also want to understand the code, not just have it written for me..
In response to Mf2
This is a tile-based game? What you want to mimic is pixel-based. You won't achieve the same level of accuracy as they did.

Besides that, there is a lot wrong with your snippet.

For starters, your Dash_Circles objects should be initialized on a turf. As of current, the effects are going into the moving mob's contents list instead of where they are standing.

The way you are using walk() is all types of sloppy; you really should be using step(). Additionally, that spawn(8) does nothing at all. Correct usage would look like:

spawn(10)
// after 1 second, everything below triggers...
world << "Code triggered!"


Your Move() proc also returns nothing when it expects to be returned a number -- in your case, 1 for success and 0 for failure. Ignoring this will lead to game-breaking behavior.

These are just a few things that stood out at first glance. But yeah, don't expect pixel-accurate behavior in tile movement mode.
Actually I am using a pixel-movement based system, and apologies i did go back and fixed the spawn thing and the walk. But how would you do it?

Also, i didn't use step because with the step, the mob would only move a certain amount of pixels, not very far or fast for that matter.
Also, i didn't use step because with the step, the mob would only move a certain amount of pixels, not very far or fast for that matter.

That's why you would use a loop of some sort to continuously move. This is better than what you are doing, which I'd consider bad practice.

An example of my own dashing:

        var/distance_moved = 0
for(distance; distance > 0; distance -= speed)
// pre-movement checks...

if(can_step(src, direction, speed))
if(distance_moved >= TILE_SIZE)
// ...

custom_step(src, dir, speed, ACTION_DASH)
distance_moved += speed
else
break

sleep(DASH_TICK_SPEED)


But how would you do it?

As I explained in my first post:

This is as simple as tracking distance traveled and generating a trail for every x movements.

Not much else to it, as seen in my snippet above.