Created button function and fixed timer issue
This commit is contained in:
40
web/game.js
40
web/game.js
@@ -170,6 +170,7 @@ function draw() {
|
||||
pop();
|
||||
}
|
||||
if (hasMoved == false) {
|
||||
time = 0;
|
||||
push();
|
||||
score();
|
||||
textSize(10);
|
||||
@@ -332,8 +333,39 @@ function spawnRandomBullet() {
|
||||
|
||||
|
||||
function homescreen() {
|
||||
push()
|
||||
square(width/2, height/2, 100)
|
||||
color(255, 0, 255, 200)
|
||||
pop()
|
||||
// push()
|
||||
// fill(0, 0, 0, 200)
|
||||
// square(0, 0, 1600)
|
||||
// pop()
|
||||
|
||||
// push()
|
||||
// fill(255, 0, 0)
|
||||
// let buttonHeight = height/2
|
||||
// rect(width/2-90, buttonHeight, 200, 40 , 20, 20, 20, 20)
|
||||
// textSize(25)
|
||||
// fill(0,0,0)
|
||||
// text("Start Game", width/2+10, buttonHeight+30)
|
||||
// if (mouseX > width/2-90 && mouseX < width/2+110 && mouseY > height/2 && mouseY < buttonHeight+40) {
|
||||
// if (mouseIsPressed) {
|
||||
// homescreenOn = false;
|
||||
// }
|
||||
// }
|
||||
// pop()
|
||||
button(0,0,0 ,width/2-90, height/2, 200, 40, "Start Game")
|
||||
|
||||
}
|
||||
|
||||
function button(r, g, b, buttonX, buttonY, buttonWidth, buttonHeight, buttonText) {
|
||||
push()
|
||||
fill(255, 0, 0)
|
||||
rect(buttonX, buttonY, buttonWidth, buttonHeight, 20, 20, 20, 20)
|
||||
textSize(25)
|
||||
fill(r,g,b)
|
||||
text(buttonText, buttonX+100, buttonY+30)
|
||||
if (mouseX > buttonX-90 && mouseX < width/2+110 && mouseY > height/2 && mouseY < buttonY+40) {
|
||||
if (mouseIsPressed) {
|
||||
homescreenOn = false;
|
||||
}
|
||||
}
|
||||
pop()
|
||||
}
|
||||
|
Reference in New Issue
Block a user