From c55ea000fdf64152f3161fa8e14909fbd832cdbc Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sat, 28 Dec 2024 19:56:42 -0800 Subject: [PATCH] whoosh animation when level up pending --- vacuum_gambit.p8 | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/vacuum_gambit.p8 b/vacuum_gambit.p8 index 96ef6e9..da676a8 100644 --- a/vacuum_gambit.p8 +++ b/vacuum_gambit.p8 @@ -157,6 +157,7 @@ function init_hpcols() end function wipe_level() + xpwhoosh = nil primary_ship = player.new() init_hpcols() pships = linked_list.new() @@ -251,6 +252,17 @@ function updategame() state = win end if (not pships.next) state = lose + + if primary_ship.xp >= primary_ship.xptarget then + if not xpwhoosh then + xpwhoosh = 0 + else + xpwhoosh += 1 + if (xpwhoosh > 60) xpwhoosh = 0 + end + else + xpwhoosh = nil + end end function _draw() @@ -346,8 +358,18 @@ function drawhud() print("XP",119,55,1) print("HP",114,122,1) fillp(0x5a5a) - vertmeter(115,58,118,117,primary_ship.xp, primary_ship.xptarget, powcols) - -- 59 px vertically + if xpwhoosh then + clip(115,58,4,60) + rectfill(115,58,118,117,0xaa) + local voff = 5*xpwhoosh+6 + rectfill(115,118-voff,118,117-voff+10,0xbb) + rectfill(115,118-voff+11,118,117-voff+20,0xba) + clip() + else + vertmeter(115,58,118,117,primary_ship.xp, primary_ship.xptarget, powcols) + end + -- 59 px vertically? or 60? off-by-1 error somewhere here or in vertmeter? + -- it's here. I think local mxs, cs, mxh, ch = primary_ship.maxshield, primary_ship.shield, primary_ship.maxhp, primary_ship.hp if (mxs > 0) and (mxh > 0) then local split = 59 * (mxs / (mxs + mxh)) \ 1 + 64