working writting (one letter)

This commit is contained in:
Mees Roelofsz
2023-12-13 13:33:56 +01:00
parent fcc6924739
commit 95f4ccc890

View File

@@ -87,7 +87,7 @@ function gameOver() {
text("Game Over", width / 2, height / 2 - 80);
pop();
push();
fill(255,255,255)
fill(255, 255, 255)
textSize(32);
text(letters[currentIndex], width / 2, height / 2);
pop();
@@ -131,20 +131,26 @@ async function keyPressed() {
if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) {
playerPosY += playerSpeed;
}
}
if (isDead) {
if (keyCode === UP_ARROW) {
}
if (isDead && keyReleasedFlag) {
if (keyCode == UP_ARROW) {
currentIndex = (currentIndex + 1) % letters.length;
keyReleasedFlag = false;
}
if (keyCode === DOWN_ARROW) {
if (keyCode == DOWN_ARROW) {
currentIndex = (currentIndex - 1 + letters.length) % letters.length;
keyReleasedFlag = false;
}
if (keyCode === ENTER) {
if (keyCode == ENTER) {
name += letters[currentIndex];
console.log(name);
keyReleasedFlag = false;
}
}
}
function keyReleased() {
keyReleasedFlag = true; // Set the flag to true when a key is released
}
function wait(waitTime) {
@@ -189,6 +195,7 @@ function draw() {
if (homescreenOn == false) {
game();
}
// keyIsDown();
}
async function randPatern() {