local x = 1
local y = 1
+local running = false
+
function playdate.update()
- for i,row in ipairs(rects) do
- for j,r in ipairs(row) do
- if r.live then
+ if not running then
+ -- automata state setup
+ for i,row in ipairs(rects) do
+ for j,r in ipairs(row) do
+ if r.live then
+ gfx.setColor(gfx.kColorBlack)
+ else
+ gfx.setColor(gfx.kColorWhite)
+ end
+
+ gfx.fillRect(r.rect)
gfx.setColor(gfx.kColorBlack)
- else
- gfx.setColor(gfx.kColorWhite)
- end
-
- gfx.fillRect(r.rect)
- gfx.setColor(gfx.kColorBlack)
- gfx.drawRect(r.rect)
+ gfx.drawRect(r.rect)
+ end
end
- end
-
- if playdate.buttonJustPressed("right") then
- x = math.min(WIDTH, x + 1)
- elseif playdate.buttonJustPressed("left") then
- x = math.max(1, x - 1)
- elseif playdate.buttonJustPressed("up") then
- y = math.max(1, y - 1)
- elseif playdate.buttonJustPressed("down") then
- y = math.min(HEIGHT, y + 1)
- end
- if playdate.buttonJustPressed("a") then
- rects[x][y].live = not rects[x][y].live
+ if playdate.buttonJustPressed("right") then
+ x = math.min(WIDTH, x + 1)
+ elseif playdate.buttonJustPressed("left") then
+ x = math.max(1, x - 1)
+ elseif playdate.buttonJustPressed("up") then
+ y = math.max(1, y - 1)
+ 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
+ elseif playdate.buttonJustPressed("b") then
+ running = true
+ end
+ else
+ -- running
end
end