added constarin to iInput

This commit is contained in:
Mees Roelofsz
2023-12-13 15:25:57 +01:00
parent 420439dead
commit 2019e194b4

View File

@@ -80,6 +80,7 @@ function score() {
function gameOver() { function gameOver() {
if (lives == 0) { if (lives == 0) {
//game over screen //game over screen
iIndex = constrain(iIndex, 0, 2);
isDead = true; isDead = true;
push(); push();
fill(255, 0, 0); fill(255, 0, 0);
@@ -137,7 +138,7 @@ async function keyPressed() {
} }
} }
if (isDead && keyReleasedFlag) { if (isDead && keyReleasedFlag) {
if ((iIndex < 2) || (iIndex > 0)) { if ((!(iIndex > 2)) || (!(iIndex < 0))) {
if (keyCode == LEFT_ARROW) { if (keyCode == LEFT_ARROW) {
iIndex -= 1; iIndex -= 1;
keyReleasedFlag = false; keyReleasedFlag = false;