Java Processing Game over Screen erstellen?

Hey ich habe eine Version von Pong erstellt um mich ein wenig rumzuprobierem. Demnach ist es weder schön noch besonders ausgereift. Ich habe folgendes gecodet und Frage mich wie ich auf Knopfdruck ein neues Spiel starten kann. Ich hab schon was implementiert was aber nicht funktioniert hatt. Vielleicht ist der Ansatz ja auch richtig. Vielen Dank:

int screen = 0;
int end = 0;
float x = 0;
float y = 0;

int xball = 500;
int yball = 500;
int xdir = 1;
int ydir = 1;



void setup(){
  
 fullScreen();
 smooth();
  
}

void draw(){
 background(38,30,38);
 strokeWeight(5);
 stroke(39,255,36);
 fill(39, 181, 36);
 rect(25,(mouseY/25)*25,25,25);
 rect(25,((mouseY/25)*25)+25,25,25);
 rect(25,((mouseY/25)*25)-25,25,25);
 rect(25,((mouseY/25)*25)-50,25,25);
 rect(25,((mouseY/25)*25)+50,25,25);
  
  
 stroke(255,39,36);
 fill(181,39,36);
  
 
  
  
 fill(255,39,36);
 stroke(181,39,36);
 rect((xball/25)*25,(yball/25)*25,25,25);
 xball = xball+xdir*4;
 yball = yball+ydir*2;
  
  
  
  if (xball > width-25){
   xdir = xdir * -1;
  }  
 
 if (xball < 25){
  screen = 1;
 }
 
 if (xball < 75){
  if (xball > 25){
  if (yball > ((mouseY/25)*25)-50){
   if(yball < ((mouseY/25)*25)+50){
   xdir = xdir * -1;
  }}}}
  
  
 if (yball > height-25 || yball < 25){
   ydir = ydir * -1;
  }
   
 if (screen > 0){
  noStroke();
  fill(0);
  rect(0,0,width,height);
  stroke(255);
  fill(255);
  textSize(150);
  text("Game Over",width/4-100,height/2);
  fill(150);
  stroke(150);
  text("again?",width/4+100,height/2+260);
  end = 1;
 }
   
}



void mouseClicked (){
  
 background(38,30,38);
 if(mouseX > width/4+100){
  if(mouseX < width/4+600){
   if(mouseY > height/2+260){
    if(mouseY < height/+310){
     if(end > 0){
      screen = -1;
      end = 0;
      xball = 500;
      yball = 500;
      xdir = 1;
      ydir = 1;
      x = 0;
      y = 0;
      
 
 
 }}}}}
  
}
programmieren, Java, Processing
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.