handle 0 shield and 1 max HP cases

This commit is contained in:
Kistaro Windrider 2024-08-18 14:40:11 -07:00
parent eebd84544b
commit c2668cefea
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -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)