working writting (one letter)
This commit is contained in:
45
web/game.js
45
web/game.js
@@ -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();
|
||||
@@ -119,32 +119,38 @@ function movementCheck() {
|
||||
|
||||
async function keyPressed() {
|
||||
if (!isDead) {
|
||||
if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) {
|
||||
playerPosX -= playerSpeed;
|
||||
if (keyIsDown(LEFT_ARROW) && playerPosX > 0 + radius) {
|
||||
playerPosX -= playerSpeed;
|
||||
}
|
||||
if (keyIsDown(RIGHT_ARROW) && playerPosX < width - radius) {
|
||||
playerPosX += playerSpeed;
|
||||
}
|
||||
if (keyIsDown(UP_ARROW) && playerPosY > 0 + radius) {
|
||||
playerPosY -= playerSpeed;
|
||||
}
|
||||
if (keyIsDown(DOWN_ARROW) && playerPosY < height - radius) {
|
||||
playerPosY += playerSpeed;
|
||||
}
|
||||
}
|
||||
if (keyIsDown(RIGHT_ARROW) && playerPosX < width - radius) {
|
||||
playerPosX += playerSpeed;
|
||||
}
|
||||
if (keyIsDown(UP_ARROW) && playerPosY > 0 + radius) {
|
||||
playerPosY -= playerSpeed;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (keyCode === DOWN_ARROW) {
|
||||
keyReleasedFlag = false;
|
||||
}
|
||||
if (keyCode == DOWN_ARROW) {
|
||||
currentIndex = (currentIndex - 1 + letters.length) % letters.length;
|
||||
}
|
||||
if (keyCode === ENTER) {
|
||||
keyReleasedFlag = false;
|
||||
}
|
||||
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() {
|
||||
|
Reference in New Issue
Block a user