From: JC Date: Mon, 31 Jul 2023 01:11:43 +0000 (-0500) Subject: Allow pressing "B" to begin running automata X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=e2b908e358020dcd9aeff95f71be51628cfb897c;p=life-pd.git Allow pressing "B" to begin running automata It doesn't run yet, but pressing B saves the state of the game and prevents player input --- diff --git a/source/main.lua b/source/main.lua index 3bab8bd..2057169 100644 --- a/source/main.lua +++ b/source/main.lua @@ -16,34 +16,41 @@ end local x = 1 local y = 1 +local running = false + function playdate.update() - for i,row in ipairs(rects) do - for j,r in ipairs(row) do - if r.live then + if not running then + -- automata state setup + for i,row in ipairs(rects) do + for j,r in ipairs(row) do + if r.live then + gfx.setColor(gfx.kColorBlack) + else + gfx.setColor(gfx.kColorWhite) + end + + gfx.fillRect(r.rect) gfx.setColor(gfx.kColorBlack) - else - gfx.setColor(gfx.kColorWhite) - end - - gfx.fillRect(r.rect) - gfx.setColor(gfx.kColorBlack) - gfx.drawRect(r.rect) + gfx.drawRect(r.rect) + end end - end - - if playdate.buttonJustPressed("right") then - x = math.min(WIDTH, 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(HEIGHT, y + 1) - end - if playdate.buttonJustPressed("a") then - rects[x][y].live = not rects[x][y].live + if playdate.buttonJustPressed("right") then + x = math.min(WIDTH, 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(HEIGHT, y + 1) + elseif playdate.buttonJustPressed("a") then + rects[x][y].live = not rects[x][y].live + elseif playdate.buttonJustPressed("b") then + running = true + end + else + -- running end end