From c2668cefea5f8ec1abf32f3adf49a7a2167d9e1f Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 18 Aug 2024 14:40:11 -0700 Subject: [PATCH] handle 0 shield and 1 max HP cases --- vacuum_gambit.p8 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 1b779bf..46fed05 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -320,6 +320,7 @@ function drawgame() end powcols=split"170,154,153,148,68" +shlcols = split"204,220,221" function drawhud() -- 112-and-right is hud zone rectfill(112, 0, 127, 127,0x56) @@ -337,12 +338,17 @@ function drawhud() inset(120,66,125,125) -- 57 px vertically - local mxs, mxh = primary_ship.maxshield, primary_ship.maxhp - if mxs + mxh > 1 then + local mxs, cs, mxh, ch = primary_ship.maxshield, primary_ship.shield, primary_ship.maxhp, primary_ship.hp + if (mxs > 0) and (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) + vertmeter(121,67,124,split-1,cs, mxs,shlcols) + vertmeter(121,split+1,124,124,ch-1, mxh-1, hpcols) + elseif mxs > 0 then + vertmeter(121,67,124,124,cs,mxs,shlcols) + elseif mxh > 1 then + line(121,124,124,124,0x89) + vertmeter(121,67,124,123,ch-1,mxh-1,hpcols) else print("!", 122, 94, 9) print("!", 121, 93, 8)