-
Notifications
You must be signed in to change notification settings - Fork 1
EndSnakeScreen
rp3002 edited this page Aug 28, 2024
·
2 revisions
The EndSnakeScreen
class in the game handles the end-of-game state for the Snake mini-game. It displays the player's final score, awards a medal based on the score, and provides options to restart the game or return to the mini-game menu.
package com.csse3200.game.screens;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.csse3200.game.GdxGame;
import com.csse3200.game.components.minigame.MiniGameConstants;
import com.csse3200.game.components.minigame.MiniGameMedals;
- Sets up the "Exit" button that returns the player to the Main Menu screen.
- Renders the screen, handles key presses, and updates the UI elements.
- Handles key presses for restarting the game or returning to the mini-game menu.
- Displays the end-of-game message, the score, the awarded medal, and provides buttons to retry or return to the mini-game menu.
- Generates a personalized message based on the player's score.
- Determines the medal awarded based on the player's score.
- Sets the background color based on the player's score and awarded medal.
- Releases resources used by the screen.