From 09ddcac1ad0244f5e2fd7c9f13b9c8867dd6ee9c Mon Sep 17 00:00:00 2001 From: Dejvino Date: Sun, 11 Aug 2024 10:16:42 +0200 Subject: [PATCH] moonbus: audio visual fuel warning improvement --- moonbus.p8 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index f1ff7f3..25b51f4 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -53,6 +53,8 @@ function load_level() engine_power=0.1 fuel_cons=0.01 + fuel_warning=0.3 + fuel_warning_on=false land_speed_limit=1 bonus_docked=1 transed_per_level=5 @@ -125,11 +127,23 @@ function _update() if plr_engine != -1 then sfx(2,2) - plr_fuel=max(0,plr_fuel-fuel_cons) + plr_fuel=max(0,min(1,plr_fuel-fuel_cons)) else sfx(-1,2) end + if plr_alive and plr_fuel < fuel_warning then + if plr_fuel <= 0.01 then + sfx(5,3) + elseif not fuel_warning_on then + fuel_warning_on=true + sfx(5,3) + end + else + fuel_warning_on=false + sfx(-1,3) + end + if plr_docked then plr_fuel=min(1,plr_fuel+fuel_cons) end @@ -273,8 +287,10 @@ function _draw() local fx=85 local fy=0 rect(fx,fy,fx+fw,fy+fh,5) - rectfill(fx+1,fy+1,fx+plr_fuel*(fw-1),fy+fh-1,plr_fuel > 0.25 and 13 or 8) - print("fuel", fx+3,fy+1,1) + if plr_fuel > 0 then + rectfill(fx+1,fy+1,fx+1+plr_fuel*(fw-2),fy+fh-1,plr_fuel > fuel_warning and 13 or 8) + end + print("fuel", fx+3,fy+1,plr_fuel <= fuel_warning and 9 or 1) -- telemetry local cr=10 @@ -725,7 +741,7 @@ __sfx__ 0001002005750087500b7500b7500a750067500375005750087500a7500b7500a75009750047500475006750097500a7500a75009750087500675006750087500a7500a75008750067500675008750097500a750 00020000226502265026150241501d150161500e1500c150061500315001150001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 010800002605000000260502163021610216102161600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +000a00082405024050240500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000