fix: keyboard inputs now respect collision — soft drop and hard drop gated on blocked
ArrowDown soft drop, Space hard drop, and Drop button all bypassed the blocked signal, letting pieces pass through frozen blocks. Now all three gate on blocked before modifying py.
This commit is contained in:
parent
b8fb60d8c4
commit
d4f353394f
1 changed files with 3 additions and 3 deletions
|
|
@ -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],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue