Browse Source

add "glide" state

main
Colin McMillen 3 years ago
parent
commit
5d600463ca
  1. 18
      borb.p8

18
borb.p8

@ -7,6 +7,7 @@ __lua__
walk = 0
stand = 1
fly = 2
glide = 3
function init_world()
player = {
@ -50,6 +51,7 @@ function _draw()
draw_player()
camera(0, 0)
print_ctr("b o r b",8,yellow)
--print(player.state.." "..player.time)
end
function draw_bg()
@ -64,7 +66,7 @@ function update_player()
dx = bool2int(btn(1)) - bool2int(btn(0))
if (dx != 0) then
if player.state == fly then
if player.state >= fly then
dx *= 2
end
player.x += dx
@ -77,10 +79,16 @@ function update_player()
end
player.y += player.vy
player.vy += 0.5
if player.vy > 0 and btn(🅾️) then
if player.state == fly then
set_state(glide)
end
player.vy = 0.2
end
if (player.y > 112) then
player.y = 112
player.vy = 0
if player.state == fly then
if player.state >= fly then
set_state(stand)
end
end
@ -90,6 +98,12 @@ function update_player()
-- update sprite
if player.state == stand then
player.spr = 1
elseif player.state == glide then
if player.time % 16 >= 14 then
player.spr = 1
else
player.spr = 3
end
elseif player.state == walk then
player.spr = (player.time / 2) % 2 + 1
else

Loading…
Cancel
Save