coldet toomgis

This commit is contained in:
James Turk 2023-04-01 17:00:18 -05:00
parent bdad4ffa32
commit 6f6d2dc1b6

View File

@ -30,7 +30,7 @@ function ampm_draw()
local fx = 78 local fx = 78
if ampm_t > 300 then if ampm_t > 300 then
tx = 140 - (ampm_t-300) tx = 140 - (ampm_t-300)
toomgis(tx, 50) toomgis_draw(tx, 50)
fx = min(tx, 78) fx = min(tx, 78)
else else
@ -88,13 +88,14 @@ vx = 0
vy = 0 vy = 0
yacc = 0 yacc = 0
function toomgis_radius()
return 8 + (pieces / MAX_PIECES) * 30
end
function add2body(n) function add2body(n)
if pieces < MAX_PIECES then if pieces < MAX_PIECES then
pieces += 1 pieces += 1
-- center hole + variance + grow outwards add(tbody, {n=n, r=toomgis_radius() + rnd(7), off=rnd(4)})
local r = 5 + rnd(5) + (pieces / MAX_PIECES) * 25
add(tbody, {n=n, r=r, off=rnd(4)})
end end
end end
@ -108,10 +109,10 @@ end
function toomgis_draw(x, y) function toomgis_draw(x, y)
--sprm(32, x, y+12, 1, 2) --printh(x..","..y)
for i=1,#tbody do for i=1,#tbody do
-- rotate drawing order -- rotate drawing order
local bs = tbody[(i+flr(th)) % #tbody + 1] local bs = tbody[(i+flr(tangle)) % #tbody + 1]
spr(bs.n, spr(bs.n,
x+4+bs.r*sin(tangle+bs.off), x+4+bs.r*sin(tangle+bs.off),
y+4+bs.r*cos(tangle+bs.off) y+4+bs.r*cos(tangle+bs.off)
@ -125,7 +126,6 @@ function toomgis_upd()
px += vx px += vx
py = max(0, py+vy) py = max(0, py+vy)
vy += yacc vy += yacc
printh("vy="..vy.." yacc="..yacc)
end end
-->8 -->8
-- level -- level
@ -144,6 +144,19 @@ levels = {
} }
lvl = levels[1] lvl = levels[1]
horizon = 64 horizon = 64
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},
}
function level_draw() function level_draw()
@ -159,10 +172,20 @@ function level_draw()
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, tline(0, 128-h+y, 128, 128-h+y,
(px-20)/(8*zoom), 2+y/(8*zoom), 1/(8*zoom), 0) (px)/(8*zoom), 2+y/(8*zoom), 1/(8*zoom), 0)
end end
toomgis_draw(20, 96-py) toomgis_draw(20, 96-py)
for item in all(items) do
if item.n != 0 then
spr(item.n, item.x-px, item.y)
-- collider
circ(item.x-px+4, item.y+4, 4, 8)
end
end
--printh(dist(px-20, py, item.x, item.y))
end end
function level_upd() function level_upd()
@ -178,7 +201,7 @@ function level_upd()
vx = 3 vx = 3
end end
if btnp(❎) and py == 0 then if btnp(❎) and py == 0 then
yacc = 10 yacc = 6
elseif py > 0 then elseif py > 0 then
yacc = -3 yacc = -3
elseif py == 0 and yacc < 0 then elseif py == 0 and yacc < 0 then
@ -187,9 +210,47 @@ function level_upd()
vy = 0 vy = 0
end end
-- check for falling off back of screen and player collide
for item in all(items) do
if item.x < px then
item.n = 0
end
local d = dist(20+8, 96-py+8, item.x+4-px, item.y+4)
--printh(item.n.." "..(item.x+4-px)..","..(item.y+4).." d="..d)
if d < toomgis_radius() and item.n != 0 then
item.n = 0
end
end
-- add item if inactive (chance increases as more slots inactive)
to_check = rnd(items)
if to_check.n == 0 then
to_check.n = flr(rnd(14)+2)
to_check.x = px + 128 + rnd(100)
to_check.y = rnd(100)
end
-- make toomgis bigger as he rolls -- make toomgis bigger as he rolls
add2body(flr(rnd(14)+2)) --add2body(flr(rnd(14)+2))
end end
-->8
-- utils
function dist(x0,y0,x1,y1)
-- scale inputs down by 6 bits
local dx=(x0-x1)/64
local dy=(y0-y1)/64
-- get distance squared
local dsq=dx*dx+dy*dy
-- in case of overflow/wrap
if(dsq<0) return 32767.99999
-- scale output back up by 6 bits
return sqrt(dsq)*64
end
__gfx__ __gfx__
000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555 000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555
000222220000000004eee440009ea9000aa77aa0060000000088880004545400099999900007400009f9f9f0cc1111cc06444660000a0a000fff4ff000055555 000222220000000004eee440009ea9000aa77aa0060000000088880004545400099999900007400009f9f9f0cc1111cc06444660000a0a000fff4ff000055555