diff --git a/examples/game-tetris.ds b/examples/game-tetris.ds index a3bfbdf..6b460d9 100644 --- a/examples/game-tetris.ds +++ b/examples/game-tetris.ds @@ -76,8 +76,8 @@ let lockTick = 0 on keydown(ev) -> px = if gameOver then px else (if paused then px else (if ev.key == "ArrowLeft" then (if px > 0 then px - 1 else px) else px)) on keydown(ev) -> px = if gameOver then px else (if paused then px else (if ev.key == "ArrowRight" then (if px < 7 then px + 1 else px) else px)) on keydown(ev) -> rotation = if gameOver then rotation else (if paused then rotation else (if ev.key == "ArrowUp" then (rotation + 1) % 4 else rotation)) -on keydown(ev) -> py = if gameOver then py else (if paused then py else (if ev.key == "ArrowDown" then (if py < 18 then py + 1 else py) else py)) -on keydown(ev) -> py = if gameOver then py else (if paused then py else (if ev.key == " " then 18 else py)) +on keydown(ev) -> py = if gameOver then py else (if paused then py else (if blocked then py else (if ev.key == "ArrowDown" then (if py < 18 then py + 1 else py) else py))) +on keydown(ev) -> py = if gameOver then py else (if paused then py else (if blocked then py else (if ev.key == " " then 18 else py))) on keydown(ev) -> paused = if ev.key == "p" then (if paused then 0 else 1) else paused -- ================================================================ @@ -313,7 +313,7 @@ view tetris_game = column [ } button "Left" { click: px = if px > 0 then px - 1 else px, variant: "secondary" } button "Right" { click: px = if px < 7 then px + 1 else px, variant: "secondary" } - button "Drop" { click: py = 18, variant: "secondary" } + button "Drop" { click: py = if blocked then py else 18, variant: "secondary" } button "Rotate" { click: rotation = (rotation + 1) % 4, variant: "secondary" } button "Reset" { click: score = 0; lines = 0; level = 1; gameOver = 0; paused = 0; piece = 6; nextPiece = 1; px = 3; py = 0; rotation = 0; g16 = [0,0,0,0,0,0,0,0,0,0]; g17 = [0,0,0,0,0,0,0,0,0,0]; g18 = [0,0,0,0,0,0,0,0,0,0]; g19 = [0,0,0,0,0,0,0,0,0,0],