local WIDTH <const> = 12
local HEIGHT <const> = 7
-local rects = {}
+local cells = {}
for i=1, WIDTH do
- rects[i] = {}
+ cells[i] = {}
for j=1, HEIGHT do
r = pd.geometry.rect.new(32 * (i-1), 32 * (j-1), 32, 32)
- rects[i][j] = { rect = r, live = false }
+ cells[i][j] = { cell = r, live = false }
end
end
function playdate.update()
if not running then
-- automata state setup
- for i,row in ipairs(rects) do
+ for i,row in ipairs(cells) do
for j,r in ipairs(row) do
if r.live then
gfx.setColor(gfx.kColorBlack)
gfx.setColor(gfx.kColorWhite)
end
- gfx.fillRect(r.rect)
+ gfx.fillRect(r.cell)
gfx.setColor(gfx.kColorBlack)
- gfx.drawRect(r.rect)
+ gfx.drawRect(r.cell)
end
end
elseif playdate.buttonJustPressed("down") then
y = math.min(HEIGHT, y + 1)
elseif playdate.buttonJustPressed("a") then
- rects[x][y].live = not rects[x][y].live
+ cells[x][y].live = not cells[x][y].live
elseif playdate.buttonJustPressed("b") then
running = true
end