Log In  
Log In  

how to create smoth gridmovement for player?so he smoothly moved to the side of the grid cell?

P#55201 2018-08-15 17:04 ( Edited 2018-08-16 03:05)

Did you have a look at the demos/collide sample that ships with pico8?
Is that what you are trying to achieve?

P#55202 2018-08-15 17:38 ( Edited 2018-08-15 21:38)

P#55204 2018-08-15 18:08 ( Edited 2018-08-15 22:08)

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)

tobiasvl ty!!!

P#55208 2018-08-15 18:47 ( Edited 2018-08-15 22:47)
:: dw817

Griddables hmm ? Let's see ...

Cart [#55219#] | Code | 2018-08-16 | No License | Embed

P#55220 2018-08-15 22:39 ( Edited 2018-08-16 02:39)

I posted a couple carts on doing this. Hope they help...

https://www.lexaloffle.com/bbs/?pid=43366&tid=29809

P#55222 2018-08-15 23:05 ( Edited 2018-08-16 03:05)

[Please log in to post a comment]

About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-05-23 21:07 | 0.029s | 4194k | Q:33