Super simple example:
function _init() x,y=0,0 -- actual sprite position new_x,new_y=0,0 -- position to move sprite to end function _update() if btnp(1) then -- 1 == right new_x+=8 end if new_x>x then x+=1 -- moves one pixel per frame end end function _draw() cls() spr(1,x,y) end |
For more directions than one, make more if tests, or perhaps a lookup table with btnp() mask values to see where you want to move based on them. You'll need to make sure you can't change direction midways in a move, because then it won't keep to the grid anymore.
P#55206 2018-08-15 18:22 ( Edited 2018-08-15 22:41)
I posted a couple carts on doing this. Hope they help...
P#55222 2018-08-15 23:05 ( Edited 2018-08-16 03:05)
[Please log in to post a comment]