//The "Game Over" screen class GameOver extends GameState { float messageWidth; String message = "GAME OVER"; PImage gameScreen; void init(GameEngine game){ println("GameOver : init()"); filter(BLUR); filter(GRAY); gameScreen = get(); textFont(game.font, 48); messageWidth = textWidth(message); cursor(); } void cleanup(){ println("GameOver : cleanup()"); } void mouseReleased(GameEngine game){ if ( mouseButton == LEFT ){ //Return to the intro screen game.popState(); //Pops the "Game Over" state game.changeState(new IntroState()); //Replaces the current PlayState, if any, with the Intro screen } } void draw(GameEngine game){ background(gameScreen); float band = 60; float bandWidth = textWidth(message) + 20; fill(255, 255, 255, 220); noStroke(); rect((width - bandWidth)/2, (height - band)/2, bandWidth, band); textSize(48); textAlign(CENTER, CENTER); fill(200, 0, 0); text(message, width/2, height/2); } }