From: JC Date: Mon, 31 Jul 2023 00:06:35 +0000 (-0500) Subject: Make a 2 dimensional array of rectangles X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=62c1624bbf64f4b13f6e5b92018948bde28f7221;p=life-pd.git Make a 2 dimensional array of rectangles --- 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())