tbody
This commit is contained in:
parent
18a44937f8
commit
8e5ff28cb1
47
toomgis.p8
47
toomgis.p8
@ -111,24 +111,22 @@ end
|
|||||||
-- toomgis
|
-- toomgis
|
||||||
|
|
||||||
tangle = 0
|
tangle = 0
|
||||||
tbody = {
|
tbody = {} -- array of items in body
|
||||||
} -- array of items in body
|
|
||||||
pieces = 1
|
|
||||||
last_guitar = 0
|
last_guitar = 0
|
||||||
do_guitar_reset = false
|
do_guitar_reset = false
|
||||||
|
|
||||||
|
GOAL = 100
|
||||||
MAX_PIECES = 200
|
MAX_PIECES = 200
|
||||||
GUITAR_DELAY = 0.2 -- time before clearing items
|
GUITAR_DELAY = 0.2 -- time before clearing items
|
||||||
GUITAR_DURATION = 0.5
|
GUITAR_DURATION = 0.5
|
||||||
GUITAR_COOLDOWN = 2
|
GUITAR_COOLDOWN = 2
|
||||||
|
|
||||||
function toomgis_radius()
|
function toomgis_radius()
|
||||||
return 8 + (pieces / MAX_PIECES) * 40
|
return 8 + (#tbody / MAX_PIECES) * 40
|
||||||
end
|
end
|
||||||
|
|
||||||
function add2body(n)
|
function add2body(n)
|
||||||
if pieces < MAX_PIECES then
|
if #tbody < MAX_PIECES then
|
||||||
pieces += 1
|
|
||||||
add(tbody, {n=n, r=toomgis_radius() + rnd(9), off=rnd(4), ejecting=false})
|
add(tbody, {n=n, r=toomgis_radius() + rnd(9), off=rnd(4), ejecting=false})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -142,7 +140,6 @@ function hitbody()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function toomgis_draw(x, y)
|
function toomgis_draw(x, y)
|
||||||
--printh(x..","..y)
|
|
||||||
for i=1,#tbody do
|
for i=1,#tbody do
|
||||||
-- rotate drawing order
|
-- rotate drawing order
|
||||||
local bs = tbody[(i+flr(tangle)) % #tbody + 1]
|
local bs = tbody[(i+flr(tangle)) % #tbody + 1]
|
||||||
@ -158,6 +155,10 @@ function toomgis_upd()
|
|||||||
tangle += vx * 0.01
|
tangle += vx * 0.01
|
||||||
px += vx
|
px += vx
|
||||||
py = max(0, py+vy)
|
py = max(0, py+vy)
|
||||||
|
if px >= 10000 then
|
||||||
|
px = 0
|
||||||
|
reset_items()
|
||||||
|
end
|
||||||
vy += yacc
|
vy += yacc
|
||||||
|
|
||||||
local to_remove = {}
|
local to_remove = {}
|
||||||
@ -171,7 +172,6 @@ function toomgis_upd()
|
|||||||
end
|
end
|
||||||
for idx in all(to_remove) do
|
for idx in all(to_remove) do
|
||||||
deli(tbody, idx)
|
deli(tbody, idx)
|
||||||
pieces -= 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-->8
|
-->8
|
||||||
@ -185,7 +185,7 @@ levels = {
|
|||||||
mapy=2,
|
mapy=2,
|
||||||
bad_item_ratio=0.12,
|
bad_item_ratio=0.12,
|
||||||
unit="CM",
|
unit="CM",
|
||||||
time=60,
|
time=300,
|
||||||
next=2,
|
next=2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -193,9 +193,9 @@ levels = {
|
|||||||
sky=2,
|
sky=2,
|
||||||
gnd=5,
|
gnd=5,
|
||||||
mapy=5,
|
mapy=5,
|
||||||
bad_item_ratio=0.2,
|
bad_item_ratio=0.16,
|
||||||
unit="M",
|
unit="M",
|
||||||
time=80,
|
time=240,
|
||||||
next=nil,
|
next=nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -207,7 +207,6 @@ function start_level(n)
|
|||||||
music(-1, 1000)
|
music(-1, 1000)
|
||||||
-- toomgis reset
|
-- toomgis reset
|
||||||
tbody = {}
|
tbody = {}
|
||||||
pieces = 1
|
|
||||||
px = 0
|
px = 0
|
||||||
py = 0
|
py = 0
|
||||||
vx = 0
|
vx = 0
|
||||||
@ -237,9 +236,7 @@ function level_draw()
|
|||||||
-- each level is 3tl/24px
|
-- each level is 3tl/24px
|
||||||
cls(lvl.sky)
|
cls(lvl.sky)
|
||||||
--- zoom should go from 16 to 2 w/ growth
|
--- zoom should go from 16 to 2 w/ growth
|
||||||
--local pieces_step = flr(pieces / 10)
|
local zoom = 16 - (14 * (#tbody / MAX_PIECES))
|
||||||
--local zoom = 16 - (14 * (pieces_step / (MAX_PIECES / 10)))
|
|
||||||
local zoom = 16 - (14 * (pieces / MAX_PIECES))
|
|
||||||
local h=24 * zoom
|
local h=24 * zoom
|
||||||
for y=0,h do
|
for y=0,h do
|
||||||
tline(0, 128-h+y, 128, 128-h+y, -- screen coordinates (entire screen scanlines)
|
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
|
-- percentage of way through guitar duration
|
||||||
local gdp = (time() - last_guitar) / GUITAR_DURATION;
|
local gdp = (time() - last_guitar) / GUITAR_DURATION;
|
||||||
if gdp < 1 then
|
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*100), 11)
|
||||||
circ(20, 104-py, 16+(gdp*75), 11)
|
circ(20, 104-py, 16+(gdp*75), 11)
|
||||||
circ(20, 104-py, 16+(gdp*50), 11)
|
circ(20, 104-py, 16+(gdp*50), 11)
|
||||||
circ(20, 104-py, 16+(gdp*25), 11)
|
circ(20, 104-py, 16+(gdp*25), 11)
|
||||||
|
else
|
||||||
|
spr(35, 20, 104-py, 2, 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw item shadows
|
-- draw item shadows
|
||||||
@ -288,9 +286,9 @@ function level_draw()
|
|||||||
streak_str = streak_str.."X"
|
streak_str = streak_str.."X"
|
||||||
end
|
end
|
||||||
rectfill(0, 0, 128, 8, 2)
|
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(time_left().."S", 60, 1, 9)
|
||||||
print("GOAL 100"..lvl.unit, 88, 1, 9)
|
print("GOAL "..GOAL..lvl.unit, 88, 1, 9)
|
||||||
end
|
end
|
||||||
|
|
||||||
function time_left()
|
function time_left()
|
||||||
@ -317,10 +315,8 @@ function draw_stink(x, y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function level_upd()
|
function level_upd()
|
||||||
printh(px)
|
|
||||||
|
|
||||||
if time_left() <= 0 then
|
if time_left() <= 0 then
|
||||||
if pieces < 100 then
|
if #tbody < GOAL then
|
||||||
start_gameover()
|
start_gameover()
|
||||||
elseif lvl.next != nil then
|
elseif lvl.next != nil then
|
||||||
start_level(lvl.next)
|
start_level(lvl.next)
|
||||||
@ -336,13 +332,10 @@ function level_upd()
|
|||||||
if btn(⬅️) then
|
if btn(⬅️) then
|
||||||
vx -= 0.05
|
vx -= 0.05
|
||||||
end
|
end
|
||||||
-- if btn(⬆️) then
|
|
||||||
-- pieces += 1
|
|
||||||
-- end
|
|
||||||
if vx < 0 then
|
if vx < 0 then
|
||||||
vx = 0
|
vx = 0
|
||||||
elseif vx > 3 then
|
elseif vx > 4 then
|
||||||
vx = 3
|
vx = 4
|
||||||
end
|
end
|
||||||
|
|
||||||
-- jump
|
-- jump
|
||||||
@ -402,7 +395,7 @@ function level_upd()
|
|||||||
to_check.n = flr(rnd(12)+2)
|
to_check.n = flr(rnd(12)+2)
|
||||||
end
|
end
|
||||||
to_check.x = px + 128 + rnd(100)
|
to_check.x = px + 128 + rnd(100)
|
||||||
to_check.y = rnd(100)
|
to_check.y = rnd(90)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user