working writting (one letter)
This commit is contained in:
15
web/game.js
15
web/game.js
@@ -132,20 +132,26 @@ async function keyPressed() {
|
|||||||
playerPosY += playerSpeed;
|
playerPosY += playerSpeed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDead) {
|
if (isDead && keyReleasedFlag) {
|
||||||
if (keyCode === UP_ARROW) {
|
if (keyCode == UP_ARROW) {
|
||||||
currentIndex = (currentIndex + 1) % letters.length;
|
currentIndex = (currentIndex + 1) % letters.length;
|
||||||
|
keyReleasedFlag = false;
|
||||||
}
|
}
|
||||||
if (keyCode === DOWN_ARROW) {
|
if (keyCode == DOWN_ARROW) {
|
||||||
currentIndex = (currentIndex - 1 + letters.length) % letters.length;
|
currentIndex = (currentIndex - 1 + letters.length) % letters.length;
|
||||||
|
keyReleasedFlag = false;
|
||||||
}
|
}
|
||||||
if (keyCode === ENTER) {
|
if (keyCode == ENTER) {
|
||||||
name += letters[currentIndex];
|
name += letters[currentIndex];
|
||||||
console.log(name);
|
console.log(name);
|
||||||
|
keyReleasedFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function keyReleased() {
|
||||||
|
keyReleasedFlag = true; // Set the flag to true when a key is released
|
||||||
|
}
|
||||||
|
|
||||||
function wait(waitTime) {
|
function wait(waitTime) {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
@@ -189,6 +195,7 @@ function draw() {
|
|||||||
if (homescreenOn == false) {
|
if (homescreenOn == false) {
|
||||||
game();
|
game();
|
||||||
}
|
}
|
||||||
|
// keyIsDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function randPatern() {
|
async function randPatern() {
|
||||||
|
Reference in New Issue
Block a user