From 762a8956658c1d0d9d554d00a028f61f8b0a7282 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Fri, 9 Aug 2024 20:23:58 +0200 Subject: [PATCH] moonbus: reset after crash --- moonbus.p8 | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index 6f565fb..80d85a3 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -4,26 +4,35 @@ __lua__ -- MoonBus -- by Dejvino -plr_alive=true -plr_win=false -plr_docked=false -plr_pos={x=5,y=8} -plr_speed={x=0.5,y=0} -plr_static=false -plr_engine=-1 -plr_fuel=1 +function reset() + plr_alive=true + plr_win=false + plr_docked=false + plr_pos={x=5,y=8} + plr_speed={x=0.5,y=0} + plr_static=false + plr_engine=-1 + plr_fuel=1 + + telem_spd={} + + gravity=0.02 + engine_power=0.1 + fuel_cons=0.01 + land_speed_limit=1 + maph=8 + cam={} +end -telem_spd={} - -gravity=0.02 -engine_power=0.1 -fuel_cons=0.01 -land_speed_limit=1 -maph=8 -cam={} +function _init() + reset() +end function _update() debug_points={} + if not plr_alive and btn(❎) then + reset() + end -- controlls plr_engine=-1 @@ -90,6 +99,7 @@ function _update() break elseif solid or plr_pos.y<=0 then plr_speed.y*=-0.75 + plr_speed.x*=0.5 plr_alive=false if (dist(plr_speed) > 1) then sfx(0) @@ -168,12 +178,14 @@ function _draw() if plr_alive then if plr_docked then + print("smooth! you docked.", 0,0,3) print("press ❎ to undock.", 32,60,11) else print("land gently to dock.", 0,0,3) end else print("oops! you crashed.", 0,0,8) + print("press ❎ to reset.", 32,60,11) end end