moonbus: HUD messaging, undocking

This commit is contained in:
Dejvino 2024-08-09 09:22:18 +02:00
parent 2446f5d659
commit 8f8fa8db7e

View File

@ -6,6 +6,7 @@ __lua__
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
@ -25,15 +26,25 @@ function _update()
-- controlls
plr_engine=-1
if plr_alive 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
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
end
if plr_docked and btn(❎) then
plr_docked=false
plr_static=false
plr_engine=⬆️
plr_speed={x=0,y=0.5}
end
end
-- engine
if plr_engine==⬆️ then
plr_speed.y+=engine_power
elseif plr_engine==⬇️ then
plr_speed.y-=engine_power
elseif plr_engine==⬅️ then
plr_speed.x-=engine_power
elseif plr_engine==➡️ then
@ -56,7 +67,7 @@ function _update()
-- crash detection
local pc=plus(plr_pos,{x=0.5,y=-0.5})
if pc.y <= maph then
if pc.y <= maph and not plr_static then
for p in all({plus(pc,clearx(unit(plr_speed,0.4))), plus(pc,cleary(unit(plr_speed,0.4)))}) do
local pmaps=mget(p.x,maph-p.y)
local target=fget(pmaps,7)
@ -65,6 +76,8 @@ function _update()
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)}
plr_docked=true
plr_static=true
sfx(1)
break
elseif solid or plr_pos.y<=0 then
@ -76,6 +89,7 @@ function _update()
plr_speed.x=0
plr_speed.y=0
plr_static=true
sfx(3)
end
break
end
@ -87,22 +101,24 @@ function _update()
end
cam={x=plr_pos.x*8-60, y=0}
camera(cam.x,cam.y)
end
function _draw()
cls()
camera(cam.x,cam.y)
map(0, 0, 0, 128-maph*8)
local px,py=to_scrn(plr_pos)
local img=0
if plr_win then
if plr_docked then
img=5
elseif not plr_alive then
img=4
elseif plr_engine==⬆️ then
img=2
elseif plr_engine==⬇️ then
img=2
elseif plr_engine==⬅️ then
img=3
elseif plr_engine==➡️ then
@ -115,9 +131,12 @@ function _draw()
pset(px,py,8)
end
-- HUD
camera(0,0)
-- telemetry
local cr=10
local cp={x=cam.x+127-cr,y=cam.y+cr}
local cp={x=127-cr,y=cr}
local spd={x=limit(telem_spd.x,1),y=limit(telem_spd.y,1)}
circ(cp.x,cp.y,cr,3)
line(cp.x,cp.y,cp.x+spd.x*cr,cp.y,11)
@ -129,6 +148,16 @@ function _draw()
line(cp.x,cp.y,cp.x+0.6*cr,cp.y+0.3*cr,5)
line(cp.x+0.6*cr,cp.y+0.3*cr,cp.x+0.2*cr,cp.y+0.8*cr,5)
end
if plr_alive then
if plr_docked then
print("press ❎ to undock.", 36,60,11)
else
print("land gently to dock.", 0,0,3)
end
else
print("oops! you crashed.", 0,0,8)
end
end
function to_scrn(p)
@ -241,7 +270,7 @@ __sfx__
000400002c2501f250132503365036650396503765035650316502f6502c650246501d6501b6501b65019650126500e65010650116500c6500d6500e6500c6500a65007650016500065000000000000000000000
010800000a4500a4500a4503d0502d0503d0502645026050264503363021630196401065003650006400063000620006100461000000000000000000000000000000000000000000000000000000000000000000
0010002030650336502f6502a6502a6502b6502c6502e650306503165033650346502f6502b6502c6502d6502e6502a65029650296502b6502d650306502f6502d6502d6502e6502f650306502c6502e6502f650
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00080000161501915026150241501d150161500e1500c150061500315001150001500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000