local pd <const> = playdate
local gfx <const> = playdate.graphics
-local WIDTH <const> = 10
-local HEIGHT <const> = 10
+local WIDTH <const> = 12
+local HEIGHT <const> = 7
local rects = {}
for i=1, WIDTH do
rects[i] = {}
for j=1, HEIGHT do
r = pd.geometry.rect.new(32 * (i-1), 32 * (j-1), 32, 32)
- rects[i][j] = { rect = r }
+ rects[i][j] = { rect = r, live = false }
end
end
function playdate.update()
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)
gfx.drawRect(r.rect)
+
end
end
- gfx.fillRect(rects[x][y].rect)
-
if playdate.buttonJustPressed("right") then
x = math.min(WIDTH, x + 1)
elseif playdate.buttonJustPressed("left") then
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
+ end
end