explode out

This commit is contained in:
James Turk 2023-04-08 23:04:25 -05:00
parent c0743ba2c5
commit fc209f724e

View File

@ -79,7 +79,7 @@ end
tangle = 0 tangle = 0
tbody = { tbody = {
} } -- array of items in body
pieces = 1 pieces = 1
MAX_PIECES = 200 MAX_PIECES = 200
px = 0 px = 0
@ -96,18 +96,15 @@ end
function add2body(n) function add2body(n)
if pieces < MAX_PIECES then if pieces < MAX_PIECES then
pieces += 1 pieces += 1
add(tbody, {n=n, r=toomgis_radius() + rnd(9), off=rnd(4)}) add(tbody, {n=n, r=toomgis_radius() + rnd(9), off=rnd(4), ejecting=false})
end end
end end
function hitbody() function hitbody()
to_remove = max(rnd(pieces * 0.5), 1) for piece in all(tbody) do
for i=0,to_remove do if rnd() < 0.2 then
if pieces == 1 then piece.ejecting = true
break
end end
pieces -= 1
deli(tbody)
end end
end end
@ -138,6 +135,19 @@ function toomgis_upd()
px += vx px += vx
py = max(0, py+vy) py = max(0, py+vy)
vy += yacc vy += yacc
local to_remove = {}
for idx, piece in pairs(tbody) do
if piece.ejecting then
piece.r += 5
if piece.r > 90 then
add(to_remove, idx)
end
end
end
for idx in all(to_remove) do
deli(tbody, idx)
end
end end
-->8 -->8
-- level -- level
@ -148,7 +158,7 @@ levels = {
sky=7, sky=7,
gnd=5, gnd=5,
mapy=2, mapy=2,
bad_item_ratio=0.1, bad_item_ratio=0.2,
unit="CM", unit="CM",
}, },
{ {
@ -282,7 +292,7 @@ function level_upd()
streak = 0 streak = 0
else else
sfx(6) sfx(6)
for i=0,streak2mult() do for i=1,streak2mult() do
add2body(item.n) add2body(item.n)
end end
streak += 1 streak += 1