class GameOverScreen implements Screen { private PlayingScreen playingScreen; public GameOverScreen(PlayingScreen playingScreen) { this.playingScreen = playingScreen; } public void draw() { background(#CCCCCC); playingScreen.draw(); fill(#77000000); noStroke(); rect(playingScreen.xOffset, playingScreen.yOffset, 6 * playingScreen.cellSize, 6 * playingScreen.cellSize); fill(#FFFFFF); textFont(headingFont); text("Game Over", width / 2, height / 4); textFont(textFont); String text = "The player using " + (playingScreen.currentPlayer instanceof Cross ? "crosses" : "circles") + " has won the game."; if (playingScreen.gameIsDraw) { text = "The game is a draw."; } text(text + "\n\nPress any key or click anywhere to play again." + playingScreen.highScoreText, width / 2, height / 2); } public void keyPressed() { setScreen(new PlayingScreen()); } public void mouseClicked() { setScreen(new PlayingScreen()); } }