From 5d600463ca446ac460dbb316cd1c57828bdee7f0 Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Thu, 8 Jul 2021 21:34:22 -0400 Subject: [PATCH] add "glide" state --- borb.p8 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/borb.p8 b/borb.p8 index e1b3714..06faf67 100644 --- a/borb.p8 +++ b/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