-
-
Save melcor76/17e8f24693f8129730f5f9099066ff46 to your computer and use it in GitHub Desktop.
js-tetris - hard drop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const KEY = { | |
SPACE: 32, | |
// ... | |
} | |
moves = { | |
[KEY.SPACE]: p => ({ ...p, y: p.y + 1 }) | |
// ... | |
}; | |
// In EventListener | |
if (event.keyCode === KEY.SPACE) { | |
// Hard drop | |
while (board.valid(p)) { | |
board.piece.move(p); | |
p = moves[KEY.DOWN](board.piece); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment