Created button function and fixed timer issue
This commit is contained in:
36
web/game.js
36
web/game.js
@@ -170,6 +170,7 @@ function draw() {
|
|||||||
pop();
|
pop();
|
||||||
}
|
}
|
||||||
if (hasMoved == false) {
|
if (hasMoved == false) {
|
||||||
|
time = 0;
|
||||||
push();
|
push();
|
||||||
score();
|
score();
|
||||||
textSize(10);
|
textSize(10);
|
||||||
@@ -332,8 +333,39 @@ function spawnRandomBullet() {
|
|||||||
|
|
||||||
|
|
||||||
function homescreen() {
|
function homescreen() {
|
||||||
|
// 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()
|
push()
|
||||||
square(width/2, height/2, 100)
|
fill(255, 0, 0)
|
||||||
color(255, 0, 255, 200)
|
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()
|
pop()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user