Actually allow selecting grid rectangle now
authorJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 00:46:25 +0000 (19:46 -0500)
committerJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 00:46:25 +0000 (19:46 -0500)
This is a bit like snake!

source/main.lua

index f96c0b4..913d60c 100644 (file)
@@ -20,8 +20,16 @@ function playdate.update()
             gfx.drawRect(r.rect)
         end
     end
+
     gfx.fillRect(rects[x][y].rect)
-    if playdate.buttonJustPressed("a") then
-        playdate.display.setInverted(not playdate.display.getInverted())
+
+    if playdate.buttonJustPressed("right") then
+        x = math.min(10, 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)
     end
 end