From 8e5ff28cb16a7b7fa08459c816681d9343c8a8e5 Mon Sep 17 00:00:00 2001 From: James Turk Date: Sun, 9 Apr 2023 21:42:00 -0500 Subject: [PATCH] tbody --- toomgis.p8 | 47 ++++++++++++++++++++--------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/toomgis.p8 b/toomgis.p8 index 89ed65b..71cfa33 100644 --- a/toomgis.p8 +++ b/toomgis.p8 @@ -111,24 +111,22 @@ end -- toomgis tangle = 0 -tbody = { -} -- array of items in body -pieces = 1 +tbody = {} -- array of items in body last_guitar = 0 do_guitar_reset = false +GOAL = 100 MAX_PIECES = 200 GUITAR_DELAY = 0.2 -- time before clearing items GUITAR_DURATION = 0.5 GUITAR_COOLDOWN = 2 function toomgis_radius() - return 8 + (pieces / MAX_PIECES) * 40 + return 8 + (#tbody / MAX_PIECES) * 40 end function add2body(n) - if pieces < MAX_PIECES then - pieces += 1 + if #tbody < MAX_PIECES then add(tbody, {n=n, r=toomgis_radius() + rnd(9), off=rnd(4), ejecting=false}) end end @@ -142,7 +140,6 @@ function hitbody() end function toomgis_draw(x, y) - --printh(x..","..y) for i=1,#tbody do -- rotate drawing order local bs = tbody[(i+flr(tangle)) % #tbody + 1] @@ -158,6 +155,10 @@ function toomgis_upd() tangle += vx * 0.01 px += vx py = max(0, py+vy) + if px >= 10000 then + px = 0 + reset_items() + end vy += yacc local to_remove = {} @@ -171,7 +172,6 @@ function toomgis_upd() end for idx in all(to_remove) do deli(tbody, idx) - pieces -= 1 end end -->8 @@ -185,7 +185,7 @@ levels = { mapy=2, bad_item_ratio=0.12, unit="CM", - time=60, + time=300, next=2, }, { @@ -193,9 +193,9 @@ levels = { sky=2, gnd=5, mapy=5, - bad_item_ratio=0.2, + bad_item_ratio=0.16, unit="M", - time=80, + time=240, next=nil, }, } @@ -207,7 +207,6 @@ function start_level(n) music(-1, 1000) -- toomgis reset tbody = {} - pieces = 1 px = 0 py = 0 vx = 0 @@ -237,9 +236,7 @@ function level_draw() -- each level is 3tl/24px cls(lvl.sky) --- zoom should go from 16 to 2 w/ growth - --local pieces_step = flr(pieces / 10) - --local zoom = 16 - (14 * (pieces_step / (MAX_PIECES / 10))) - local zoom = 16 - (14 * (pieces / MAX_PIECES)) + local zoom = 16 - (14 * (#tbody / MAX_PIECES)) local h=24 * zoom for y=0,h do tline(0, 128-h+y, 128, 128-h+y, -- screen coordinates (entire screen scanlines) @@ -251,11 +248,12 @@ function level_draw() -- 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) + else + spr(35, 20, 104-py, 2, 2) end -- draw item shadows @@ -288,9 +286,9 @@ function level_draw() streak_str = streak_str.."X" end rectfill(0, 0, 128, 8, 2) - print("SIZE "..pieces..lvl.unit.." "..streak_str.." ", 1, 1, 9) + print("SIZE "..#tbody..lvl.unit.." "..streak_str.." ", 1, 1, 9) print(time_left().."S", 60, 1, 9) - print("GOAL 100"..lvl.unit, 88, 1, 9) + print("GOAL "..GOAL..lvl.unit, 88, 1, 9) end function time_left() @@ -317,10 +315,8 @@ function draw_stink(x, y) end function level_upd() - printh(px) - if time_left() <= 0 then - if pieces < 100 then + if #tbody < GOAL then start_gameover() elseif lvl.next != nil then start_level(lvl.next) @@ -336,13 +332,10 @@ function level_upd() if btn(⬅️) then vx -= 0.05 end - -- if btn(⬆️) then - -- pieces += 1 - -- end if vx < 0 then vx = 0 - elseif vx > 3 then - vx = 3 + elseif vx > 4 then + vx = 4 end -- jump @@ -402,7 +395,7 @@ function level_upd() to_check.n = flr(rnd(12)+2) end to_check.x = px + 128 + rnd(100) - to_check.y = rnd(100) + to_check.y = rnd(90) end end