Can someone Help me with a Timer

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);
  }
}

You can Create a time like that:

Click here to see the code
float currentTime = 0;

float timeToNextSeite = 10;//in sekunden

int seite = 0;

void setup() {
  size(800, 800);
}
void draw() {
  switch(seite) {
  case 0:
    showSeite1();
    break;
  case 1:
    showSeite2();
    break;
  case 2:
    showSeite3();
    break;
  }
}
void showSeite1() {
  background(255, 0, 0);
  fill(0);
  textSize(40);
  //str(int) makes the int to a string
  textAlign(CENTER, CENTER);
  text(str(round(currentTime)), 0, 0, width, height);
  currentTime += 1 / frameRate;
  if (currentTime >= timeToNextSeite) {
    //10 Seconds are over
    seite++;//seite = seite + 1; in short

    currentTime -= timeToNextSeite;
  }
}
void showSeite2() {
  background(0, 255, 0);
  fill(0);
  textSize(40);
  //str(int) makes the int to a string
  textAlign(CENTER, CENTER);
  text(str(round(currentTime)), 0, 0, width, height);
  currentTime += 1 / frameRate;
  if (currentTime >= timeToNextSeite) {
    //10 Seconds are over
    seite++;//seite = seite + 1; in short

    currentTime -= timeToNextSeite;
  }
}
void showSeite3() {
  background(0, 0, 255);
  fill(0);
  textSize(40);
  //str(int) makes the int to a string
  textAlign(CENTER, CENTER);
  text(str(round(currentTime)), 0, 0, width, height);
  currentTime += 1 / frameRate;
  if (currentTime >= timeToNextSeite) {
    //10 Seconds are over
    seite = 0;//seite = seite + 1; in short

    currentTime -= timeToNextSeite;
  }
}

And I would recommend you to use an Enum:

Click here to see the code
//Create an Enum "class"
enum SCENE {
  //Here are the Types from the enum 
  START, 
    GAME, 
    WIN, 
    LOSE, 
    LOAD
    //ect.
}
//Create a variable
SCENE currentScene = SCENE.START;
void example(){
  //now you can set the scene
  currentScene = SCENE.START;
  //or
  currentScene = SCENE.GAME;
  //ect
}

I hope I could help you
Flolo :slight_smile: