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