coldet toomgis
This commit is contained in:
parent
bdad4ffa32
commit
6f6d2dc1b6
81
toomgis.p8
81
toomgis.p8
@ -30,7 +30,7 @@ function ampm_draw()
|
||||
local fx = 78
|
||||
if ampm_t > 300 then
|
||||
tx = 140 - (ampm_t-300)
|
||||
toomgis(tx, 50)
|
||||
toomgis_draw(tx, 50)
|
||||
fx = min(tx, 78)
|
||||
else
|
||||
|
||||
@ -88,13 +88,14 @@ vx = 0
|
||||
vy = 0
|
||||
yacc = 0
|
||||
|
||||
function toomgis_radius()
|
||||
return 8 + (pieces / MAX_PIECES) * 30
|
||||
end
|
||||
|
||||
function add2body(n)
|
||||
if pieces < MAX_PIECES then
|
||||
pieces += 1
|
||||
-- center hole + variance + grow outwards
|
||||
local r = 5 + rnd(5) + (pieces / MAX_PIECES) * 25
|
||||
add(tbody, {n=n, r=r, off=rnd(4)})
|
||||
add(tbody, {n=n, r=toomgis_radius() + rnd(7), off=rnd(4)})
|
||||
end
|
||||
end
|
||||
|
||||
@ -108,10 +109,10 @@ end
|
||||
|
||||
|
||||
function toomgis_draw(x, y)
|
||||
--sprm(32, x, y+12, 1, 2)
|
||||
--printh(x..","..y)
|
||||
for i=1,#tbody do
|
||||
-- rotate drawing order
|
||||
local bs = tbody[(i+flr(th)) % #tbody + 1]
|
||||
local bs = tbody[(i+flr(tangle)) % #tbody + 1]
|
||||
spr(bs.n,
|
||||
x+4+bs.r*sin(tangle+bs.off),
|
||||
y+4+bs.r*cos(tangle+bs.off)
|
||||
@ -125,7 +126,6 @@ function toomgis_upd()
|
||||
px += vx
|
||||
py = max(0, py+vy)
|
||||
vy += yacc
|
||||
printh("vy="..vy.." yacc="..yacc)
|
||||
end
|
||||
-->8
|
||||
-- level
|
||||
@ -144,6 +144,19 @@ levels = {
|
||||
}
|
||||
lvl = levels[1]
|
||||
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()
|
||||
|
||||
@ -159,10 +172,20 @@ function level_draw()
|
||||
local h=24 * zoom
|
||||
for y=0,h do
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
function level_upd()
|
||||
@ -178,7 +201,7 @@ function level_upd()
|
||||
vx = 3
|
||||
end
|
||||
if btnp(❎) and py == 0 then
|
||||
yacc = 10
|
||||
yacc = 6
|
||||
elseif py > 0 then
|
||||
yacc = -3
|
||||
elseif py == 0 and yacc < 0 then
|
||||
@ -187,9 +210,47 @@ function level_upd()
|
||||
vy = 0
|
||||
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
|
||||
add2body(flr(rnd(14)+2))
|
||||
--add2body(flr(rnd(14)+2))
|
||||
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__
|
||||
000022220000000000444400000ee000aaaaaaaa0000000000555500045454000099990000087000000000000cccccc00077700000000a0000ffff0000005555
|
||||
000222220000000004eee440009ea9000aa77aa0060000000088880004545400099999900007400009f9f9f0cc1111cc06444660000a0a000fff4ff000055555
|
||||
|
Loading…
Reference in New Issue
Block a user