From 62c1624bbf64f4b13f6e5b92018948bde28f7221 Mon Sep 17 00:00:00 2001 From: JC Date: Sun, 30 Jul 2023 19:06:35 -0500 Subject: [PATCH] Make a 2 dimensional array of rectangles --- source/main.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/main.lua b/source/main.lua index 5cedb2d..8bda86b 100644 --- a/source/main.lua +++ b/source/main.lua @@ -3,13 +3,18 @@ local gfx = playdate.graphics local rects = {} for i=1, 10 do - rects[i] = pd.geometry.rect.new(32 * (i-1), 32 * (i-1), 32, 32) + rects[i] = {} + for j=1, 10 do + rects[i][j] = pd.geometry.rect.new(32 * (i-1), 32 * (j-1), 32, 32) + end end function playdate.update() - for i,r in ipairs(rects) do - gfx.drawRect(r) + for i,row in ipairs(rects) do + for j,r in ipairs(row) do + gfx.drawRect(r) + end end if playdate.buttonJustPressed("a") then playdate.display.setInverted(not playdate.display.getInverted()) -- 2.20.1