moonbus: fuel and fix multiple dockings

This commit is contained in:
Dejvino 2024-08-09 19:10:34 +02:00
parent 8f8fa8db7e
commit d6df107843

View File

@ -11,11 +11,13 @@ 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.2
engine_power=0.1
fuel_cons=0.01
land_speed_limit=1
maph=8
cam={}
@ -25,7 +27,7 @@ function _update()
-- controlls
plr_engine=-1
if plr_alive then
if plr_alive and plr_fuel>0 then
if not plr_docked then
if btn(⬆️) then plr_engine=⬆️ end
if btn(⬇️) then plr_engine=⬇️ end
@ -37,6 +39,7 @@ function _update()
plr_static=false
plr_engine=⬆️
plr_speed={x=0,y=0.5}
sfx(4)
end
end
@ -53,10 +56,15 @@ function _update()
if plr_engine != -1 then
sfx(2,2)
plr_fuel=max(0,plr_fuel-fuel_cons)
else
sfx(-1,2)
end
if plr_docked then
plr_fuel=min(1,plr_fuel+fuel_cons)
end
-- move objects
move(plr_pos,plr_speed,0.1)
@ -72,7 +80,7 @@ function _update()
local pmaps=mget(p.x,maph-p.y)
local target=fget(pmaps,7)
local solid=fget(pmaps,0)
if plr_win != true and target and dist(plr_speed) < land_speed_limit and p.y < pc.y then
if target and dist(plr_speed) < land_speed_limit and p.y < pc.y then
plr_win=true
plr_speed={x=0,y=0}
plr_pos={x=flr(plr_pos.x+0.5),y=flr(plr_pos.y+0.5)}
@ -134,6 +142,15 @@ function _draw()
-- HUD
camera(0,0)
-- fuel
local fw=20
local fh=6
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)
-- telemetry
local cr=10
local cp={x=127-cr,y=cr}
@ -151,7 +168,7 @@ function _draw()
if plr_alive then
if plr_docked then
print("press ❎ to undock.", 36,60,11)
print("press ❎ to undock.", 32,60,11)
else
print("land gently to dock.", 0,0,3)
end
@ -268,10 +285,10 @@ __map__
1010101010101010101010101010101010101010101010101010101414101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__sfx__
000400002c2501f250132503365036650396503765035650316502f6502c650246501d6501b6501b65019650126500e65010650116500c6500d6500e6500c6500a65007650016500065000000000000000000000
010800000a4500a4500a4503d0502d0503d0502645026050264503363021630196401065003650006400063000620006100461000000000000000000000000000000000000000000000000000000000000000000
0010002030650336502f6502a6502a6502b6502c6502e650306503165033650346502f6502b6502c6502d6502e6502a65029650296502b6502d650306502f6502d6502d6502e6502f650306502c6502e6502f650
010800000a4500a4500a4503d0502d0503d0502645026050264503d61421630216301d6201c6101a6150000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0001002005750087500b7500b7500a750067500375005750087500a7500b7500a75009750047500475006750097500a7500a75009750087500675006750087500a7500a75008750067500675008750097500a750
00080000161501915026150241501d150161500e1500c150061500315001150001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
010800003d61421630264502605026450216302162021610216102161600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000