experimenting with colors + changed main menu to change based on size

This commit is contained in:
Mees Roelofsz
2024-01-16 10:21:52 +01:00
parent eb188ee83b
commit 9eb06d9f6f
2 changed files with 19 additions and 17 deletions

View File

@@ -3,6 +3,8 @@
const width = 1260; const width = 1260;
const height = 620; const height = 620;
let requesteddata = []; let requesteddata = [];
let buttonWidth = width/ 6
let buttonHeight = buttonWidth/5
// Menu variables // Menu variables
let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''); let letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
let currentIndex = [0, 0, 0]; let currentIndex = [0, 0, 0];
@@ -321,7 +323,7 @@ function draw() {
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, 200, 40) rect(width / 2, height / 2, buttonWidth, buttonHeight)
pop() pop()
} }
if (buttonSelectHome == 1) { if (buttonSelectHome == 1) {
@@ -329,7 +331,7 @@ function draw() {
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 + 50, 200, 40) rect(width / 2, height / 2 + height/12, buttonWidth, buttonHeight)
pop() pop()
} }
} }
@@ -349,7 +351,7 @@ function draw() {
strokeWeight(2) strokeWeight(2)
fill(0, 0, 0, 0) fill(0, 0, 0, 0)
rectMode(CENTER); rectMode(CENTER);
rect(width / 2, height / 2, 200, 40) rect(width / 2, height / 2, buttonWidth, buttonHeight)
pop() pop()
} }
if (buttonSelectPause == 1) { if (buttonSelectPause == 1) {
@@ -358,7 +360,7 @@ function draw() {
strokeWeight(2) strokeWeight(2)
fill(0, 0, 0, 0) fill(0, 0, 0, 0)
rectMode(CENTER); rectMode(CENTER);
rect(width / 2, height / 2 + 50, 200, 40) rect(width / 2, height / 2 + height/12, buttonWidth, buttonHeight)
pop() pop()
} }
} }

View File

@@ -17,46 +17,46 @@ function keyPressed() {
function homescreen() { function homescreen() {
textAlign(CENTER); textAlign(CENTER);
button(255, 255, 255, width / 2, height / 2, 200, 40, "Start Game") button(255, 255, 255, width / 2, height / 2, "Start Game")
button(255, 255, 255, width / 2, height / 2 + 50, 200, 40, "Scores") button(255, 255, 255, width / 2, height / 2 + height/12, "Scores")
push() push()
stroke(255, 255, 255) stroke(4,217,255)
strokeWeight(5) strokeWeight(5)
fill(0, 255, 0, 0) fill(0, 255, 0, 0)
rect(width/4*3, height/2, 300, 400) rect(width/5*4, height/2, width/4, height/1.5)
pop() pop()
//highscores rectangle //highscores rectangle
push() push()
textSize(50) textSize(50)
fill(255, 255, 255) fill(255, 255, 255)
text("Highscores", width/4, 200) text("Highscores", width/5, height/4)
pop() pop()
push() push()
fill(255, 255, 255) fill(255, 255, 255)
textSize(25) textSize(25)
textAlign(CENTER) textAlign(CENTER, CENTER)
for (let i = 0; i < requesteddata.length; i++) { for (let i = 0; i < requesteddata.length; i++) {
text(i + 1 + ". " + requesteddata[i].Naam + ": " + requesteddata[i].Score, width/4, 250 + (i * 30)) text(i + 1 + ". " + requesteddata[i].Naam + ": " + requesteddata[i].Score, width/5, height/3 + (i * 30))
} }
pop() pop()
push() push()
stroke(255, 255, 255) stroke(4,217,255)
strokeWeight(5) strokeWeight(5)
fill(0, 255, 0, 0) fill(0, 255, 0, 0)
rect(width/4, height/2, 300, 400) rect(width/5, height/2, width/4, height/1.5)
pop() pop()
push() push()
textSize(50) textSize(50)
fill(255, 255, 255) fill(255, 255, 255)
text("Controls", width/4*3, 200) text("Controls", width/5*4, height/4)
pop() pop()
} }
function button(r, g, b, buttonX, buttonY, buttonWidth, buttonHeight, buttonText) { function button(r, g, b, buttonX, buttonY, buttonText) {
push() push()
fill(0, 0, 50) fill(0, 0, 50)
rectMode(CENTER); rectMode(CENTER);
@@ -74,6 +74,6 @@ function pauseMenu(){
textSize(50); textSize(50);
fill(255, 255, 255); fill(255, 255, 255);
text("Paused", width / 2, height / 2 - 100); text("Paused", width / 2, height / 2 - 100);
button(255, 255, 255, width / 2, height / 2, 200, 40, "Resume"); button(255, 255, 255, width / 2, height / 2, "Resume");
button(255, 255, 255, width / 2, height / 2 + 50, 200, 40, "Main Menu"); button(255, 255, 255, width / 2, height / 2 + height/12, "Main Menu");
} }