I visit a timer during the game when side is on 1 for 10 seconds afterwards side should be set to 2
import processing.sound.*;
boolean startp = true;
float c;
int seite, score, rx, ry;
SoundFile theme;
SoundFile plus;
SoundFile win;
void setup() {
colorMode(HSB);
seite = 0;
score = 0;
fullScreen();
frameRate(60);
textAlign(CENTER);
theme = new SoundFile(this, "theme.mp3");
plus = new SoundFile(this, "plus.mp3");
win = new SoundFile(this, "Wini.mp3");
theme.loop();
}
void draw () {
if(seite==0){
background(#292929);
if (c >= 255) c=0; else c++;
fill(c, 255, 255);
textSize(55*displayDensity);
text("Follow the Rect", width/2, height/3.8);
fill(#545454);
rect(width/4, height/2.5, width/2, height/12);
fill(#FFFFFF);
textSize(40*displayDensity);
text("Play", width/2, height/2.2);
if(mousePressed = mouseX > width/4 && mouseX < width/4 + width/2 && mouseY > height/2.5 && mouseY < height/2.5 + height/12){
delay(300);
theme.stop();
mouseX = width/2;
mouseY = height/2;
seite=1;
}
}
if (seite==1) {
background(#292929);
textSize(50*displayDensity);
text("Score: "+score, width/2, height/12);
rectMode(CORNER);
fill(#535353);
rect(width/8, height/4.5, width/1.3, height/1.4, 7*displayDensity);
stroke(#00DCFF);
strokeWeight(12.0);
strokeCap(ROUND);
rectMode(CENTER);
line(mouseX, mouseY, rx, ry);
strokeWeight(0);
stroke(#FFFFFF);
if (startp == false) {
fill(#A80000);
rect(rx, ry, width/15, height/30);
} else {
rx = int(random(width/7.98, width/1.28));
ry = int(random(height/4.48, height/1.38));
startp = false;
}
if (dist(mouseX, mouseY, rx, ry)<=width/15+height/30) {
plus.play();
score++;
startp = true;
}
if(score>=10){
startp = true;
seite = 2;
delay(50);
win.play();
}
}
if(seite==2){
background(#292929);
text("Gewonnen", width/2, height/2);
}
}