We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey I was wondering how I would be able to go about making a gameover screen when a collision occurs. Right now i have a static wall which is called wal2 in the code below and i'm using the dist function to detect when my mouse is touching the ellipse and what I want is for it to change to screen GAMEOVER when the collision is true.
void draw() {
if (screen == MAIN_MENU) {
MAIN_MENU();
} else if (screen == INSTRUCTIONS) {
INSTRUCTIONS();
} else if (screen == GAMEOVER) {
GAMEOVER();
} else if (screen == STORY_1) {
STORY_1();
} else if (screen == LEVEL_1) {
LEVEL_1();
}
}
`
void LEVEL_1() {
// wall collisions// boolean collision = true;
if (collision) { screen = GAMEOVER; } else { screen = LEVEL_1; }
if (dist(wal2_x, wal2_y, mouseX, mouseY)<=162) { collision = true; } }`
Answers
Duplicate
See instead: https://forum.processing.org/two/discussion/25015/making-a-gameover-screen-when-a-collision-occurs