From 18a44937f8e440f281c3db28906b99b89cf8aadf Mon Sep 17 00:00:00 2001 From: James Turk Date: Sun, 9 Apr 2023 21:04:20 -0500 Subject: [PATCH] guitar working --- toomgis.p8 | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/toomgis.p8 b/toomgis.p8 index e78460a..89ed65b 100644 --- a/toomgis.p8 +++ b/toomgis.p8 @@ -115,8 +115,10 @@ tbody = { } -- array of items in body pieces = 1 last_guitar = 0 +do_guitar_reset = false MAX_PIECES = 200 +GUITAR_DELAY = 0.2 -- time before clearing items GUITAR_DURATION = 0.5 GUITAR_COOLDOWN = 2 @@ -215,18 +217,14 @@ function start_level(n) -- level reset lvl = levels[n] lvl_start_time = time() - items = { - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - {x=0, y=0, n=0}, - } + reset_items() +end + +function reset_items() + items = {} + for i=0,10 do + add(items, {x=0, y=0, n=0}) + end end function level_draw() @@ -250,8 +248,14 @@ function level_draw() end toomgis_draw(20, 96-py) - if time() - last_guitar < GUITAR_DURATION then + -- percentage of way through guitar duration + local gdp = (time() - last_guitar) / GUITAR_DURATION; + if gdp < 1 then spr(35, 20, 104-py, 2, 2) + circ(20, 104-py, 16+(gdp*100), 11) + circ(20, 104-py, 16+(gdp*75), 11) + circ(20, 104-py, 16+(gdp*50), 11) + circ(20, 104-py, 16+(gdp*25), 11) end -- draw item shadows @@ -358,11 +362,15 @@ function level_upd() last_guitar = time() -- now with three amazing jams sfx(rnd({14,15,16})) + do_guitar_reset = true + elseif (guitar_elapsed > GUITAR_DELAY) and do_guitar_reset then + reset_items() + do_guitar_reset = false end -- check for falling off back of screen and player collision for item in all(items) do - if item.x < px then + if item.x < (px-20) then item.n = 0 end @@ -371,11 +379,11 @@ function level_upd() if d < toomgis_radius() and item.n != 0 then -- item collision if item.n > 16 then - sfx(5) + sfx(5, 0) hitbody() streak = 0 else - sfx(6) + sfx(6, 0, 0, 4*streak2mult()) for i=1,streak2mult() do add2body(item.n) end @@ -633,7 +641,7 @@ __sfx__ 361400000050200502275520050200502275520050200502275522455027552005022755227500275522455227550275002755227500275002755227500275002755224550275522750027552245522455222552 001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0003000000503165531d5532155324553265532655325553225531e5531a5531855317553195531e5532055323553255532555325553255532555324553235532355322553215531d5531a5531a5531a55319553 -010200002157124571245712457124571245712457120571095710d5710d5710d5710d5710d5710d5710a57121571245712457124571245712457124571205710a5710d5710d5710d5710d5710d5710d5710a571 +000100000c5600e5600e5600c5600e56010560105600e56010560115601156010560115601356013560115601356015560155601356017560185601856017560185601a5601a560185601c5601d5601d5601c560 011400002e4542e4542e4542e45400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 01180000220522205227052240522405229052270522705216052160521b05218052180521d0521b0521b052220522205227052240522405229052270522705216052160521b05218052180521d0521b0521b052 011800000670006700067500675000700067500670006750007000070006750067500070006750067000675006700067000675006750007000675006700067500070000700067500675000700067500670006750