Make a 2 dimensional array of rectangles
authorJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 00:06:35 +0000 (19:06 -0500)
committerJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 00:06:35 +0000 (19:06 -0500)
source/main.lua

index 5cedb2d..8bda86b 100644 (file)
@@ -3,13 +3,18 @@ local gfx <const> = 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())