one hit mode, fix vertmeter

full height meters overflowed p8num range
This commit is contained in:
Kistaro Windrider 2024-08-18 01:28:12 -07:00
parent 4f8b861cdb
commit fa0cff1ffc
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -338,11 +338,16 @@ function drawhud()
inset(120,66,125,125) inset(120,66,125,125)
-- 57 px vertically -- 57 px vertically
local mxs, mxh = primary_ship.maxshield, primary_ship.maxhp local mxs, mxh = primary_ship.maxshield, primary_ship.maxhp
local split = 57 * (mxs / (mxs + mxh-1)) \ 1 + 66 if mxs + mxh > 1 then
line(121, split, 124, split, 0xba) local split = 57 * (mxs / (mxs + mxh-1)) \ 1 + 66
vertmeter(121,67,124,split-1,primary_ship.shield, mxs,{204,220,221}) line(121, split, 124, split, 0xba)
vertmeter(121,split+1,124,124,primary_ship.hp-1, mxh-1, hpcols) vertmeter(121,67,124,split-1,primary_ship.shield, mxs,{204,220,221})
fillp(0) 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 end
function draw_gun_info(lbl,fgc,x,y,gun) function draw_gun_info(lbl,fgc,x,y,gun)
@ -368,9 +373,9 @@ function draw_gun_info(lbl,fgc,x,y,gun)
end end
function vertmeter(x0,y0,x1,y1,val,maxval,cols) 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 h = y1-y0
local px = -flr(-(h*val)\maxval) local px = val/maxval * h \ 1
local ncols = #cols local ncols = #cols
local firstcol = ((h-px)*ncols\h)+1 local firstcol = ((h-px)*ncols\h)+1
local lastbottom = y0+(h*firstcol\ncols) local lastbottom = y0+(h*firstcol\ncols)
@ -906,6 +911,11 @@ player = ship_m.new{
mknew(player, mknew(player,
function(p) function(p)
p.main_gun = zap_gun.new() p.main_gun = zap_gun.new()
-- ONE HIT MODE
-- p.hp = 1
-- p.maxhp = 1
-- p.shield = 0
-- p.maxshield = 0
end end
) )