dded constrain based on menu

This commit is contained in:
Mees Roelofsz
2024-01-23 12:55:40 +01:00
parent b23fab4025
commit 98840d6a72

View File

@@ -111,7 +111,7 @@ async function keyPressed() {
}
}
}
if (scorescreenOn && keyReleasedFlag) {
if (scorescreenOn && keyReleasedFlag && entered) {
buttonSelect = constrain(buttonSelect, 0, 1);
if (keyCode == UP_ARROW) {
buttonSelect -= 1;
@@ -189,22 +189,27 @@ function wait(waitTime) {
});
}
function nameSubmit() {
iIndex = constrain(iIndex, 0, 2);
if ((!(iIndex > 2)) || (!(iIndex < 0))) {
if (keyCode == LEFT_ARROW) {
console.log(iIndex);
iIndex -= 1;
keyReleasedFlag = false;
}
if (keyCode == RIGHT_ARROW) {
console.log(iIndex);
iIndex += 1;
keyReleasedFlag = false;
}
}
if (keyCode == UP_ARROW) {
currentIndex[iIndex] = (currentIndex[iIndex] + 1) % letters.length;
console.log(currentIndex[iIndex])
keyReleasedFlag = false;
}
if (keyCode == DOWN_ARROW) {
currentIndex[iIndex] = (currentIndex[iIndex] - 1 + letters.length) % letters.length;
console.log(currentIndex[iIndex])
keyReleasedFlag = false;
}
if (keyCode == ENTER) {