shuffle some panel stuff around, remove unreasonable source logic

This commit is contained in:
Kistaro Windrider 2023-09-04 00:39:55 -07:00
parent 31fb5b83e9
commit 78fe254e96
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -294,6 +294,7 @@ panel = {
-- negative == mid-fall -- negative == mid-fall
-- positive == bounce -- positive == bounce
-- frames left -- frames left
state="idle"
} }
mknew(panel) mknew(panel)
@ -313,6 +314,7 @@ prpblkp = {14,13,2,7}
newblock = { newblock = {
function() function()
return panel.new{ return panel.new{
id=1,
plt=redblkp, plt=redblkp,
sx=83,sy=1, sx=83,sy=1,
ey=2, as=0, ey=2, as=0,
@ -320,6 +322,7 @@ newblock = {
end, end,
function() function()
return panel.new{ return panel.new{
id=2,
plt=ylwblkp, plt=ylwblkp,
sx=83,sy=11, sx=83,sy=11,
ey=2,as=0, ey=2,as=0,
@ -327,6 +330,7 @@ newblock = {
end, end,
function() function()
return panel.new{ return panel.new{
id=3,
plt=grnblkp, plt=grnblkp,
sx=78,sy=11, sx=78,sy=11,
ey=2,as=0, ey=2,as=0,
@ -334,6 +338,7 @@ newblock = {
end, end,
function() function()
return panel.new{ return panel.new{
id=4,
plt=blublkp, plt=blublkp,
sx=83,sy=6, sx=83,sy=6,
ey=2,as=0, ey=2,as=0,
@ -341,6 +346,7 @@ newblock = {
end, end,
function() function()
return panel.new{ return panel.new{
id=5,
plt=prpblkp, plt=prpblkp,
sx=73,sy=11, sx=73,sy=11,
ey=2,as=0, ey=2,as=0,
@ -427,15 +433,15 @@ end
-- gameplay logic -- gameplay logic
game={ game={
incoming_frac = 0 incoming_frac = 0,
speed = 0 speed = 0,
gravity_lag = 30 gravity_lag = 30,
pop_lag = 20 pop_lag = 20,
stop_frames = 0 stop_frames = 0,
stop_max = 1 stop_max = 1,
life = 180 life = 180,
life_max = 180 life_max = 180,
} }
mknew(game, function(ret) mknew(game, function(ret)
@ -444,11 +450,11 @@ mknew(game, function(ret)
board[i] = { board[i] = {
nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, nopanel,
} }
end
ret.board = board ret.board = board
ret.garbage_queue = {} ret.garbage_queue = {}
ret.garbage_source = source.new() ret.garbage_source = source.new()
ret.floor_source = source.new() ret.floor_source = source.new()
end
end) end)
function game:update() function game:update()
@ -457,46 +463,6 @@ end
function game:draw() function game:draw()
end end
function shuffle(tbl)
local n = #tbl
for i=1,n-1 do
local idx = (rnd(n-i+1)&-1)+i
if (idx != i) tbl[idx], tbl[i] = tbl[i], tbl[idx]
end
end
source={
lumps = 3
metalumps = 3
metalumpiness = 2
}
mknew(source, function(ret)
ret.bucket = {}
ret.lumpqueue = {}
ret.rejects = {}
end)
function source:pick()
local lq, b := self.lumpqueue, bucket
for i=#lq/self.metalumpiness,self.metalumps do
local p := rnd(newblock)
for i=1,self.metalumpiness do
add(lq, p)
end
-- todo: draw individual panels
-- note: individual panels
-- must derive from the prototypes.
-- still not sure what the best
-- bag algorithm is; I think this
-- algorithm fills too much.
-- todo: rewrite to only redraw
-- when only one bag remains.
-- todo: actual pick algorithm
-- todo: rejection and redraw algorithm
end
end
__gfx__ __gfx__
0000000000111000011011000000000009999900066666000eeeee00077777000aaaaa0001111111000000000000000000000000000000000000000000000000 0000000000111000011011000000000009999900066666000eeeee00077777000aaaaa0001111111000000000000000000000000000000000000000000000000