Allow swapping between running and editing
authorJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 01:32:51 +0000 (20:32 -0500)
committerJC <dev@jacobcasper.com>
Mon, 31 Jul 2023 01:32:51 +0000 (20:32 -0500)
Also make display refresh rate less epilepsy inducing during runtime

source/main.lua

index ce2c572..cc8aee4 100644 (file)
@@ -47,8 +47,12 @@ function draw(cells)
 end
 
 function playdate.update()
+    if playdate.buttonJustPressed("b") then
+        running = not running
+    end
     if not running then
         -- automata state setup
+        pd.display.setRefreshRate(30)
         draw(cells)
 
         if playdate.buttonJustPressed("right") then
@@ -61,11 +65,11 @@ function playdate.update()
             y = math.min(HEIGHT, y + 1)
         elseif playdate.buttonJustPressed("a") then
             cells[x][y].live = not cells[x][y].live
-        elseif playdate.buttonJustPressed("b") then
-            running = true
         end
     else
         -- running
+        -- Make running less epileptic while letting interaction remain smooth
+        pd.display.setRefreshRate(2)
         draw(cells)
         cells = generation(cells)
     end