ID:1693904
 
(See the best response by Kaiochao.)
At the moment movement is jagged in my game. I'm not sure if its just me but how do I go about fixing it?

mob
proc
MoveSpeed()
src.speed = (0.008 * src.udex) + 4 + cmsboost

Get_Speed()
src.speed = (0.008 * src.udex) + 4 + cmsboost
return src.speed




world
icon_size = 32
fps = 25
#define TILE_WIDTH 32
#define TILE_HEIGHT 32
#define TICK_LAG 0.4 //set to (10 / world.fps) a define is faster, though

atom/movable
var
speed = 4
move_delay = 4 * TICK_LAG
tmp
last_move = -1000
Move(atom/NewLoc,Dir=0,step_x=0,step_y=0)
move_delay = speed * TICK_LAG
//set up glide sizes before the move
//ensure this is a step, not a jump
if(src.loc && get_dist(src,NewLoc)==1)
if(last_move + move_delay > world.time)
return 0
. = get_dir(src,NewLoc)
if(. & . - 1) //if a diagonal move
src.glide_size = sqrt(TILE_WIDTH**2 + TILE_HEIGHT**2) / move_delay * TICK_LAG
//glide value must be based on the hypotenuse
else if(. < 4) //north or south case
src.glide_size = TILE_HEIGHT / move_delay * TICK_LAG
//glide value must be based on the adjacent
else //east or west case
src.glide_size = TILE_WIDTH / move_delay * TICK_LAG
//glide value must be based on the opposite
. = ..(NewLoc,Dir,step_x,step_y)
if(.)
last_move = world.time
return .
. = ..(NewLoc,Dir,step_x,step_y)


byond://99.244.157.106:800
Well one thing to mention here, why are you doing this yourself? There's demos that show how to do this already.

http://www.byond.com/developer/FIREking/SmoothTileMovement

Also, are you getting this only when you host the game? (I get this no matter what when I host a game)
This is actually Ter's code.

You should make sure that either one of your MoveSpeed() or Get_Speed() procs is being called and returns what you expect. At this point, I can't say what values for src.speed work well, especially not knowing your desired result.
I originally was using FIREking's smooth tile movement, and it was smooth as fuck I was so happy but as soon as I started hosting the game it was laggy. So I switch to Ter's version, but the same thing happened(but a lot less and consistent with hosting/not hosting). Its why I have both Movespeed() and Get_Speed(), Movespeed() proc was for FIREking's and Get_Speed() was for Ter's.

/*world
fps = 40

mob
var/w,a,s,d = 0

Login()
..()
winset(client, "w", "parent=macro;name=w;command=keydown+w")
winset(client, "w+up", "parent=macro;name=w+up;command=keyup+w")

winset(client, "a", "parent=macro;name=a;command=keydown+a")
winset(client, "a+up", "parent=macro;name=a+up;command=keyup+a")

winset(client, "s", "parent=macro;name=s;command=keydown+s")
winset(client, "s+up", "parent=macro;name=s+up;command=keyup+s")

winset(client, "d", "parent=macro;name=d;command=keydown+d")
winset(client, "d+up", "parent=macro;name=d+up;command=keyup+d")

spawn move_loop()

proc/move_loop()
if(world.time >= move_time) //should we do anything?
if(!step(src, (s && (SOUTH || s)) | (w && (NORTH || w)) | (a && (WEST || a)) | (d && (EAST || d)))) //try desired direction
if(!step(src, (s && (SOUTH || s)) | (w && (NORTH || w)))) //that failed, try north or south
step(src, (a && (WEST || a)) | (d && (EAST || d))) //that failed, try east or west
spawn(world.tick_lag) move_loop() //return, and do it again

verb/keydown(k as text)
set hidden = 1
set instant = 1
if(k == "w") w = 1
if(k == "a") a = 1
if(k == "s") s = 1
if(k == "d") d = 1

verb/keyup(k as text)
set hidden = 1
set instant = 1
if(k == "w") w = 0
if(k == "a") a = 0
if(k == "s") s = 0
if(k == "d") d = 0



//get_speed_delay(n) takes an argument speed "n" and returns how long it would take to travel 1 tile at this speed in 10ths of a second
proc/get_speed_delay(n)
return (world.icon_size * world.tick_lag) / (!n ? 1 : n)

//get_glide_size(n, dir) takes an argument speed "n", and direction "dir", and returns the smoothest possible glide_size setting
proc/get_glide_size(n, dir)
return (dir & (dir - 1)) ? n + (n >> 1) : n

atom/movable
var/speed = 4
var/tmp/move_time = 0
var/tmp/transferring = 0

Move()
if(!src.loc) return ..()

if(world.time < src.move_time) return 0

if(transferring) return 0

. = ..()

if(.)
src.move_time = world.time + get_speed_delay(src.speed)
src.glide_size = get_glide_size(src.speed, src.dir)

return .

proc/Transfer(atom/location)
if(!location) return

src.transferring = 1

spawn(get_speed_delay(src.speed) - world.tick_lag)
src.x = location.x
src.y = location.y
src.z = location.z

spawn(world.tick_lag)
src.transferring = 0

*/


mob
proc
MoveSpeed()
src.speed = (0.008 * src.udex) + 4 + cmsboost

Get_Speed()
src.speed = (0.008 * src.udex) + 4 + cmsboost
return src.speed




world
icon_size = 32
fps = 25
#define TILE_WIDTH 32
#define TILE_HEIGHT 32
#define TICK_LAG 0.4 //set to (10 / world.fps) a define is faster, though

atom/movable
var
speed = 4
move_delay = 4 * TICK_LAG
tmp
last_move = -1000
Move(atom/NewLoc,Dir=0,step_x=0,step_y=0)
move_delay = speed * TICK_LAG
//set up glide sizes before the move
//ensure this is a step, not a jump
if(src.loc && get_dist(src,NewLoc)==1)
if(last_move + move_delay > world.time)
return 0
. = get_dir(src,NewLoc)
if(. & . - 1) //if a diagonal move
src.glide_size = sqrt(TILE_WIDTH**2 + TILE_HEIGHT**2) / move_delay * TICK_LAG
//glide value must be based on the hypotenuse
else if(. < 4) //north or south case
src.glide_size = TILE_HEIGHT / move_delay * TICK_LAG
//glide value must be based on the adjacent
else //east or west case
src.glide_size = TILE_WIDTH / move_delay * TICK_LAG
//glide value must be based on the opposite
. = ..(NewLoc,Dir,step_x,step_y)
if(.)
last_move = world.time
return .
. = ..(NewLoc,Dir,step_x,step_y)


Is it that only the host suffers from this problem or is it just the best that it'll ever be?
I need to reference lummox to this. I'm having the same issues and I've got a topic for it:

http://www.byond.com/forum/?post=1675744

Finally I know I'm not the only one experiencing this.
step_x and step_y are terrible in ss13 and cause jagged movement, we have to use pixel_x and pixel_y not sure if that applys here though.
Best response
If you're actually using pixel movement (step_x, step_y), you really shouldn't have any delays in between steps.
In response to Sgt.Marine
I noticed that I couldn't really see much if any jagged movement when using Forum Account's side scroller library. After some investigation I saw he was using pixel_x and y instead of the built in pixel movement.

I think there's problems with it.