From fa0cff1ffc411f03367609500203a08fdad02173 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 18 Aug 2024 01:28:12 -0700 Subject: [PATCH] one hit mode, fix vertmeter full height meters overflowed p8num range --- vacuum_gambit.p8 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 8891c79..7a1a4b2 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -338,11 +338,16 @@ function drawhud() inset(120,66,125,125) -- 57 px vertically local mxs, mxh = primary_ship.maxshield, primary_ship.maxhp - local split = 57 * (mxs / (mxs + mxh-1)) \ 1 + 66 - line(121, split, 124, split, 0xba) - vertmeter(121,67,124,split-1,primary_ship.shield, mxs,{204,220,221}) - vertmeter(121,split+1,124,124,primary_ship.hp-1, mxh-1, hpcols) - fillp(0) + if mxs + mxh > 1 then + local split = 57 * (mxs / (mxs + mxh-1)) \ 1 + 66 + line(121, split, 124, split, 0xba) + vertmeter(121,67,124,split-1,primary_ship.shield, mxs,{204,220,221}) + vertmeter(121,split+1,124,124,primary_ship.hp-1, mxh-1, hpcols) + else + print("!", 122, 94, 9) + print("!", 121, 93, 8) + end + fillp(0) end function draw_gun_info(lbl,fgc,x,y,gun) @@ -368,9 +373,9 @@ function draw_gun_info(lbl,fgc,x,y,gun) end function vertmeter(x0,y0,x1,y1,val,maxval,cols) - if (val <= 0 or maxval <= 0) return + if ((val <= 0) or (maxval <= 0)) return local h = y1-y0 - local px = -flr(-(h*val)\maxval) + local px = val/maxval * h \ 1 local ncols = #cols local firstcol = ((h-px)*ncols\h)+1 local lastbottom = y0+(h*firstcol\ncols) @@ -906,6 +911,11 @@ player = ship_m.new{ mknew(player, function(p) p.main_gun = zap_gun.new() + -- ONE HIT MODE + -- p.hp = 1 + -- p.maxhp = 1 + -- p.shield = 0 + -- p.maxshield = 0 end )