We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
shouldn't you check
circulos[i].hit(mouseX,mouseY)
ANDcirculos[j].hit(mouseX,mouseY)
(with
j
)thanks, but dont work... when you play this game you only lose if the circle that you are making bigger touch in other circle...
if you want to try the game: https://www.kongregate.com/games/aeiowu/hundreds
https://Forum.Processing.org/two/discussion/15473/readme-how-to-format-code-and-text
http://Studio.ProcessingTogether.com/sp/pad/export/ro.9NGjx94YMTtlu
http://JeffreyThompson.org/collision-detection/point-circle.php
not sure but radius isn't what ellipse is using, it's diameter
https://www.processing.org/reference/ellipse_.html
https://www.processing.org/reference/ellipseMode_.html
in the game it's not only when mouse is pressed but it's enough when mouse is over a circle without being pressed
yes the original game is when mouse is on top of the circle, but my variation the circle grow when mouse is pressed. i used radius and on the construction of the ellipse I make
ellipse(xc,yc,2*radius,2*radius)
...