Gameover section

edited January 12 in Questions about Code

Hi,

I'm making a game for a school project. The game is like Hundreds of Android and iOS and I have a little trouble with gameover section. I make a class to the circles and I want for each time the mousepressed is active and the mouse is on top of a circle, if that circle touch on other circle the gamestate change.

in my class i have this to the collision:

 boolean colide(Circulo c){
   return dist(x,y,c.x,c.y) <= raio + c.raio;
 }

and this to see when mouse is hover a circle:

   boolean hit(int px, int py){
     if(dist(px,py,x,y)<raio){
       return true;
     }else{
       return false;
     }
   }

and I try to make something like this:

  for(int j=0; j<numcirc-1; j++){
    for(int i=j+1; i<numcirc; i++){
      if(circulos[i].colide(circulos[j]) && mousePressed && circulos[i].hit(mouseX,mouseY)){
        gamestate = 2;
      }
    }
  }

but only work with some collisions...

hope someone can help me. thanks

Answers

Sign In or Register to comment.