I have a simple game that has collisions and the player will lose life when the player touches an enemy. I have a method that checks if the player isAlive and if the method returns false than the game will stop and will exit the window. If the player is dead I call my stop method which stops the program but keeps the window open and frozen. How could I make it so that the whole window closes and what method would I put it in?
isAlive()
public static void isAlive() {
if(HUD.getHEALTH() < 0) {
stop();
}
stop()
public synchronized static void stop() {
try {
thread.join();
running = false;
} catch(Exception e) {
e.printStackTrace();
}
}
Sorry if this is a repeat or duplicate I just can't find my specific problem on this website. I've already looked. If you have a possible solution or something that can help please share it. Please and thank you!