completed name ui

This commit is contained in:
Mees Roelofsz
2024-01-16 15:05:54 +01:00
parent ed670dc361
commit d77bba94ce
2 changed files with 76 additions and 64 deletions

View File

@@ -113,21 +113,22 @@ function gameOver() {
fill(255, 0, 0); fill(255, 0, 0);
textSize(40); textSize(40);
textAlign(CENTER); textAlign(CENTER);
text("Game Over", width / 2, height / 2 - 80); text("Game Over", width / 2, height / 2 - height/6);
fill(255, 255, 255) fill(255, 255, 255)
textSize(18); textSize(18);
textAlign(CENTER); textAlign(CENTER);
text("Score: " + int(time), width / 2, height / 2 - 55); text("Score: " + int(time), width / 2, height / 2 - height/8);
textSize(32); textSize(32);
textAlign(CENTER, CENTER);
text(letters[currentIndex[0]], width / 2 - 30, height / 2); text(letters[currentIndex[0]], width / 2 - 30, height / 2);
text(letters[currentIndex[1]], width / 2, height / 2); text(letters[currentIndex[1]], width / 2, height / 2);
text(letters[currentIndex[2]], width / 2 + 30, height / 2); text(letters[currentIndex[2]], width / 2 + 30, height / 2);
text("Restart", width / 2, height / 2 + 45); text("Restart", width / 2, height / 2 + height/12);
text("Main Menu", width / 2, height / 2 + 90); text("Main Menu", width / 2, height / 2 + height/6);
pop(); pop();
} }
} }
@@ -294,41 +295,13 @@ function nameSubmit() {
keyReleasedFlag = false; keyReleasedFlag = false;
} }
} }
function nameDraw() { function nameDraw(positiony) {
if (entered) {
if (buttonSelectDead == 0) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2 - 15, 90, 40)
pop()
}
if (buttonSelectDead == 1) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2 + 30, 110, 40)
pop()
}
if (buttonSelectDead == 2) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2 + 75, 160, 40)
pop()
}
}
else {
if (iIndex == 0) { if (iIndex == 0) {
push() push()
stroke(205, 205, 205) stroke(205, 205, 205)
strokeWeight(2) strokeWeight(2)
fill(0, 0, 0, 0) fill(0, 0, 0, 0)
rect(width / 2 - 30, height / 2 - 15, 30, 40) rect(width / 2 - 30, height / positiony, 30, 40)
pop() pop()
} }
if (iIndex == 1) { if (iIndex == 1) {
@@ -336,7 +309,7 @@ function nameDraw() {
stroke(205, 205, 205) stroke(205, 205, 205)
strokeWeight(2) strokeWeight(2)
fill(0, 0, 0, 0) fill(0, 0, 0, 0)
rect(width / 2, height / 2 - 15, 30, 40) rect(width / 2, height / positiony, 30, 40)
pop() pop()
} }
if (iIndex == 2) { if (iIndex == 2) {
@@ -344,10 +317,10 @@ function nameDraw() {
stroke(205, 205, 205) stroke(205, 205, 205)
strokeWeight(2) strokeWeight(2)
fill(0, 0, 0, 0) fill(0, 0, 0, 0)
rect(width / 2 + 30, height / 2 - 15, 30, 40) rect(width / 2 + 30, height / positiony, 30, 40)
pop() pop()
} }
}
} }
// the function draw() is called every frame // the function draw() is called every frame
function draw() { function draw() {
@@ -408,7 +381,35 @@ function draw() {
} }
} }
if (isDead) { if (isDead) {
nameDraw(); if (entered) {
if (buttonSelectDead == 0) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2, 90, 40)
pop()
}
if (buttonSelectDead == 1) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2 + height/12, 110, 40)
pop()
}
if (buttonSelectDead == 2) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 2 + height/6, 160, 40)
pop()
}
}
else {
nameDraw(2);
}
} }
} }
async function randPatern() { async function randPatern() {

View File

@@ -73,17 +73,28 @@ function pauseMenu() {
} }
function scoremenu() { function scoremenu() {
textAlign(CENTER); textAlign(CENTER, CENTER);
textSize(50); textSize(50);
fill(255, 255, 255); fill(255, 255, 255);
text("Score", width / 2, height / 2 - height / 6); text("Score", width / 2, height / 4);
textSize(32); textSize(32);
text(letters[currentIndex[0]], width / 2 - 30, height / 2); text(letters[currentIndex[0]], width / 2 - 30, height / 3);
text(letters[currentIndex[1]], width / 2, height / 2); text(letters[currentIndex[1]], width / 2, height / 3);
text(letters[currentIndex[2]], width / 2 + 30, height / 2); text(letters[currentIndex[2]], width / 2 + 30, height / 3);
if (scorescreenOn && keyReleasedFlag) { if (scorescreenOn && keyReleasedFlag) {
nameSubmit(); nameSubmit();
} }
nameDraw();
if (entered) {
push()
stroke(205, 205, 205)
strokeWeight(2)
fill(0, 0, 0, 0)
rect(width / 2, height / 3, 90, 40)
pop()
}
else {
nameDraw(3);
}
} }