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.
I posted a couple carts on doing this. Hope they help...
[Please log in to post a comment]