Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
Processing stop tracking mouse X

I'm doing the GameOver Screen of my game and I ran into a problem. If the GameOver screen comes up and then if you move the mouse it goes back into the game because of the mouseX.

How can I make it so that the mouseX no longer reacts from this point on?

Code:

int score = 0;
float x_2 = 300;        
float y_0 = 250;  
float y_2 = 650;   
int distanz = 0;
int currentXValue = 0;
int savedXValue = currentXValue;
PImage LilaAuto, GruenAuto, SchwarzAuto, LilaAuto_Main;


void setup() {
    size(450,700);
  
    LilaAuto =loadImage("https://raw.githubusercontent.com/Tf187/Slot-Game-Processing/main/LilaAuto.png");
    LilaAuto_Main =loadImage("https://raw.githubusercontent.com/Tf187/Slot-Game-Processing/main/LilaAuto.png");
}

void draw() {              
            
    background(204);
            
    image(LilaAuto,50,y_0, 100,100);   
    y_0--;
    if(y_0<1) {
        y_0= 650;
    }
         
    fill(204);
    image(LilaAuto_Main,mouseX,y_2, 100,100);  //Auto vom Spieler 
    y_2--;
    if(y_2<1) {
        y_2= 650;
    }
            
    image(LilaAuto,x_2,y_0, 100,100);  
    y_0--;
   
    fill(1);
    textSize(25);
    text("Score:", 10,25);
    text(score,75,25);
           
    float d= dist(mouseX,y_0,x_2,y_2);  //Messung der Distanz
    if(d < 100) {
        score = score+1;
    }  
                     
    if(d < 60) {
        gameOver();
    }
}

void gameOver() {
    score = 0;
    background(120);

    textAlign(CENTER);
    text("GameOver", 250,250); 
}

I thank you in advance for the replies

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

One way you could do this is by using noLoop(). That way, draw() won't be executed, which it doesn't have to, because the screen isn't changing.

void gameOver() {
  score = 0;
  background(120);

  textAlign(CENTER);
  text("GameOver", 250,250);
  noLoop();
}

If you then want to start looping again (because the user restarted the game for example), you can call the loop() function (for example in a keyPressed()), which will makes draw() execute again as usual. This could look something like this:

void keyPressed() {
  if(key == 'R' || key == 'r') {
    loop();
  }
}
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda