From 31fb5b83e93ff3ebf83ddd2a4e7f1b3f776c0c1b Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Sun, 6 Aug 2023 23:02:19 -0700 Subject: [PATCH] incomplete start of piece gen --- panel_extreme.p8 | 79 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/panel_extreme.p8 b/panel_extreme.p8 index c56ca5a..7f69dc8 100644 --- a/panel_extreme.p8 +++ b/panel_extreme.p8 @@ -279,6 +279,9 @@ end -->8 -- panel drawing +-- empty panel placeholder +nopanel = {} + -- panel in ordinary state panel = { -- plt: palette as table @@ -419,6 +422,82 @@ function ants:draw() end end end + +-->8 +-- gameplay logic + +game={ + incoming_frac = 0 + speed = 0 + gravity_lag = 30 + pop_lag = 20 + + stop_frames = 0 + stop_max = 1 + life = 180 + life_max = 180 +} + +mknew(game, function(ret) + local board = {} + for i=1,12 do + board[i] = { + nopanel, nopanel, nopanel, nopanel, nopanel, nopanel, + } + ret.board = board + ret.garbage_queue = {} + ret.garbage_source = source.new() + ret.floor_source = source.new() + end +end) + +function game:update() +end + +function game:draw() +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__ 0000000000111000011011000000000009999900066666000eeeee00077777000aaaaa0001111111000000000000000000000000000000000000000000000000 00000000012221001221221000000000988888206bbbbb30eddddd207cccccd0a999994012222222300040400000000000000000000000000000000000000000