moonbus: fuel and fix multiple dockings
This commit is contained in:
parent
8f8fa8db7e
commit
d6df107843
31
moonbus.p8
31
moonbus.p8
@ -11,11 +11,13 @@ plr_pos={x=5,y=8}
|
|||||||
plr_speed={x=0.5,y=0}
|
plr_speed={x=0.5,y=0}
|
||||||
plr_static=false
|
plr_static=false
|
||||||
plr_engine=-1
|
plr_engine=-1
|
||||||
|
plr_fuel=1
|
||||||
|
|
||||||
telem_spd={}
|
telem_spd={}
|
||||||
|
|
||||||
gravity=0.02
|
gravity=0.02
|
||||||
engine_power=0.2
|
engine_power=0.1
|
||||||
|
fuel_cons=0.01
|
||||||
land_speed_limit=1
|
land_speed_limit=1
|
||||||
maph=8
|
maph=8
|
||||||
cam={}
|
cam={}
|
||||||
@ -25,7 +27,7 @@ function _update()
|
|||||||
|
|
||||||
-- controlls
|
-- controlls
|
||||||
plr_engine=-1
|
plr_engine=-1
|
||||||
if plr_alive then
|
if plr_alive and plr_fuel>0 then
|
||||||
if not plr_docked then
|
if not plr_docked then
|
||||||
if btn(⬆️) then plr_engine=⬆️ end
|
if btn(⬆️) then plr_engine=⬆️ end
|
||||||
if btn(⬇️) then plr_engine=⬇️ end
|
if btn(⬇️) then plr_engine=⬇️ end
|
||||||
@ -37,6 +39,7 @@ function _update()
|
|||||||
plr_static=false
|
plr_static=false
|
||||||
plr_engine=⬆️
|
plr_engine=⬆️
|
||||||
plr_speed={x=0,y=0.5}
|
plr_speed={x=0,y=0.5}
|
||||||
|
sfx(4)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,10 +56,15 @@ function _update()
|
|||||||
|
|
||||||
if plr_engine != -1 then
|
if plr_engine != -1 then
|
||||||
sfx(2,2)
|
sfx(2,2)
|
||||||
|
plr_fuel=max(0,plr_fuel-fuel_cons)
|
||||||
else
|
else
|
||||||
sfx(-1,2)
|
sfx(-1,2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if plr_docked then
|
||||||
|
plr_fuel=min(1,plr_fuel+fuel_cons)
|
||||||
|
end
|
||||||
|
|
||||||
-- move objects
|
-- move objects
|
||||||
move(plr_pos,plr_speed,0.1)
|
move(plr_pos,plr_speed,0.1)
|
||||||
|
|
||||||
@ -72,7 +80,7 @@ function _update()
|
|||||||
local pmaps=mget(p.x,maph-p.y)
|
local pmaps=mget(p.x,maph-p.y)
|
||||||
local target=fget(pmaps,7)
|
local target=fget(pmaps,7)
|
||||||
local solid=fget(pmaps,0)
|
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_win=true
|
||||||
plr_speed={x=0,y=0}
|
plr_speed={x=0,y=0}
|
||||||
plr_pos={x=flr(plr_pos.x+0.5),y=flr(plr_pos.y+0.5)}
|
plr_pos={x=flr(plr_pos.x+0.5),y=flr(plr_pos.y+0.5)}
|
||||||
@ -134,6 +142,15 @@ function _draw()
|
|||||||
-- HUD
|
-- HUD
|
||||||
camera(0,0)
|
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
|
-- telemetry
|
||||||
local cr=10
|
local cr=10
|
||||||
local cp={x=127-cr,y=cr}
|
local cp={x=127-cr,y=cr}
|
||||||
@ -151,7 +168,7 @@ function _draw()
|
|||||||
|
|
||||||
if plr_alive then
|
if plr_alive then
|
||||||
if plr_docked then
|
if plr_docked then
|
||||||
print("press ❎ to undock.", 36,60,11)
|
print("press ❎ to undock.", 32,60,11)
|
||||||
else
|
else
|
||||||
print("land gently to dock.", 0,0,3)
|
print("land gently to dock.", 0,0,3)
|
||||||
end
|
end
|
||||||
@ -268,10 +285,10 @@ __map__
|
|||||||
1010101010101010101010101010101010101010101010101010101414101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
1010101010101010101010101010101010101010101010101010101414101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
__sfx__
|
__sfx__
|
||||||
000400002c2501f250132503365036650396503765035650316502f6502c650246501d6501b6501b65019650126500e65010650116500c6500d6500e6500c6500a65007650016500065000000000000000000000
|
000400002c2501f250132503365036650396503765035650316502f6502c650246501d6501b6501b65019650126500e65010650116500c6500d6500e6500c6500a65007650016500065000000000000000000000
|
||||||
010800000a4500a4500a4503d0502d0503d0502645026050264503363021630196401065003650006400063000620006100461000000000000000000000000000000000000000000000000000000000000000000
|
010800000a4500a4500a4503d0502d0503d0502645026050264503d61421630216301d6201c6101a6150000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
0010002030650336502f6502a6502a6502b6502c6502e650306503165033650346502f6502b6502c6502d6502e6502a65029650296502b6502d650306502f6502d6502d6502e6502f650306502c6502e6502f650
|
0001002005750087500b7500b7500a750067500375005750087500a7500b7500a75009750047500475006750097500a7500a75009750087500675006750087500a7500a75008750067500675008750097500a750
|
||||||
00080000161501915026150241501d150161500e1500c150061500315001150001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
00080000161501915026150241501d150161500e1500c150061500315001150001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
010800003d61421630264502605026450216302162021610216102161600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
Loading…
Reference in New Issue
Block a user