From 2446f5d659ae4ff9f1a9e418bb2065a1d0a8b925 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Fri, 9 Aug 2024 08:54:52 +0200 Subject: [PATCH] moonbus: docking telemetry --- moonbus.p8 | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index 1d48f85..308d6f9 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -11,6 +11,8 @@ plr_speed={x=0.5,y=0} plr_static=false plr_engine=-1 +telem_spd={} + gravity=0.02 engine_power=0.2 land_speed_limit=1 @@ -59,7 +61,6 @@ function _update() local pmaps=mget(p.x,maph-p.y) local target=fget(pmaps,7) local solid=fget(pmaps,0) - add(debug_points,p) if plr_win != true and target and dist(plr_speed) < land_speed_limit and p.y < pc.y then plr_win=true plr_speed={x=0,y=0} @@ -81,6 +82,10 @@ function _update() end end + if plr_alive then + telem_spd=mul(plr_speed,1) + end + cam={x=plr_pos.x*8-60, y=0} camera(cam.x,cam.y) end @@ -110,8 +115,20 @@ function _draw() pset(px,py,8) end - local p=plr_pos - print(p.x.." "..p.y, cam.x, cam.y) + -- telemetry + local cr=10 + local cp={x=cam.x+127-cr,y=cam.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) + line(cp.x,cp.y,cp.x,cp.y-spd.y*cr,11) + circ(cp.x+spd.x*cr,cp.y-spd.y*cr,1,dist(telem_spd) lim) then + return val*lim/abs(val) + end + return val +end __gfx__ 000000000000000000000000000000000000aa00000000000000b000000000000000000000000000000000000000000000000000000000000000000000000000 00a9a90000a9a90000a9a90000a9a90000a9000000a9a9000000b000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -215,7 +238,7 @@ __map__ 1010101010101010141010101010101010101010101010101013110000111210101010101010101010101013110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 1010101010101010101010101010101010101010101010101010101414101010101010101010101010101010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __sfx__ -000400003665038650396503965039650396503765035650316502f6502c6502965027650226501d65019650166501465012650116500e6500c6500a650076500465001650006500000000000000000000000000 +000400002c2501f250132503365036650396503765035650316502f6502c650246501d6501b6501b65019650126500e65010650116500c6500d6500e6500c6500a65007650016500065000000000000000000000 010800000a4500a4500a4503d0502d0503d0502645026050264503363021630196401065003650006400063000620006100461000000000000000000000000000000000000000000000000000000000000000000 0010002030650336502f6502a6502a6502b6502c6502e650306503165033650346502f6502b6502c6502d6502e6502a65029650296502b6502d650306502f6502d6502d6502e6502f650306502c6502e6502f650 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000