Log In  
Follow
tastyl

I'm new to PICO-8, and am trying to get a basic top-down movement system. So far I have this:

left = btn(⬅️)
right = btn(➡️)
up = btn(⬆️)
down = btn(⬇️)

xspd = (num(right) - num(left)) * player.speed
yspd = (num(down) - num(up)) * player.speed

if fget(player.x + xspd, player.y) == 0 then
	xspd = 0
end

if fget(player.x, player.y + yspd) == 0 then
	yspd = 0
end

player.x = player.x + xspd
player.y = player.y + yspd

num() takes in a boolean, and outputs a number (true being 1, false being 0)
The problem I have, is that I'm trying to stop the player if they hit a wall (The wall's sprite having flag 0), and I'm not sure what to do. Does anyone know what's going on?

1
1 comment