From 7b0fd5c3ef06d1e3b1ff6cf83120f711b64750e3 Mon Sep 17 00:00:00 2001 From: Dejvino Date: Fri, 9 Aug 2024 21:12:25 +0200 Subject: [PATCH] moonbus: docking hints --- moonbus.p8 | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/moonbus.p8 b/moonbus.p8 index 80d85a3..3349c0b 100644 --- a/moonbus.p8 +++ b/moonbus.p8 @@ -13,6 +13,10 @@ function reset() plr_static=false plr_engine=-1 plr_fuel=1 + plr_landings=0 + plr_transed=0 + plr_money=0 + plr_target={x=8,y=2} telem_spd={} @@ -21,6 +25,7 @@ function reset() fuel_cons=0.01 land_speed_limit=1 maph=8 + bonus_docked=1 cam={} end @@ -95,6 +100,7 @@ function _update() plr_pos={x=flr(plr_pos.x+0.5),y=flr(plr_pos.y+0.5)} plr_docked=true plr_static=true + plr_landings+=1 sfx(1) break elseif solid or plr_pos.y<=0 then @@ -149,7 +155,25 @@ function _draw() pset(px,py,8) end + -- target + if plr_alive then + local tx,ty=to_scrn(plr_target) + local dst=dist(plr_pos,plr_target) + local c=flr(t())%2==0 and 3 or 11 + if dst > 8 then + local dir=atan2(tx-px,ty-py) + line(px+4+cos(dir)*10,py+4+sin(dir)*10,tx+4,ty+4,c) + end + if dst > 3 then + print("웃",tx,ty+2,c) + else + print("__",tx,ty+4,c) + end + end + + -- -- HUD + -- camera(0,0) -- fuel @@ -187,6 +211,9 @@ function _draw() print("oops! you crashed.", 0,0,8) print("press ❎ to reset.", 32,60,11) end + print("⌂"..plr_landings, fx,fy+fh+2+0,3) + print("웃"..plr_transed, fx,fy+fh+2+8,3) + print("✽"..plr_money, fx,fy+fh+2+16,3) end function to_scrn(p) @@ -229,8 +256,9 @@ function neg(p) return mul(p,-1) end -function dist(p) - return abs(p.x) + abs(p.y) +function dist(p,p2) + p2=p2 or {x=0,y=0} + return abs(p.x-p2.x) + abs(p.y-p2.y) end function unit(p,u)