Skip to content

Instantly share code, notes, and snippets.

@Kaiochao
Last active June 24, 2017 04:43
Show Gist options
  • Save Kaiochao/2bce637144eefe202e8a40de3b24838d to your computer and use it in GitHub Desktop.
Save Kaiochao/2bce637144eefe202e8a40de3b24838d to your computer and use it in GitHub Desktop.
BYOND Sub-Pixel Movement allows for moving by any floating-point number of pixels.
atom/movable
var
sub_step_x = 0
sub_step_y = 0
proc
PixelMove(x, y)
var
whole_x = 0
whole_y = 0
if(x)
sub_step_x += x
whole_x = round(sub_step_x, 1)
sub_step_x -= whole_x
if(y)
sub_step_y += y
whole_y = round(sub_step_y, 1)
sub_step_y -= whole_y
if(whole_x || whole_y)
step_size = max(abs(whole_x), abs(whole_y))
Move(loc, dir, step_x + whole_x, step_y + whole_y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment