Package com.csse3200.game.screens
Class SnakeScreen
java.lang.Object
com.badlogic.gdx.ScreenAdapter
com.csse3200.game.screens.PausableScreen
com.csse3200.game.screens.MiniGameScreen
com.csse3200.game.screens.SnakeScreen
- All Implemented Interfaces:
com.badlogic.gdx.Screen
Represents the screen for the Snake game.
Handles the rendering of the game components.
-
Field Summary
Fields inherited from class com.csse3200.game.screens.MiniGameScreen
oldScreen, oldScreenServices
Fields inherited from class com.csse3200.game.screens.PausableScreen
game, resting
-
Constructor Summary
ConstructorsConstructorDescriptionSnakeScreen
(GdxGame game, com.badlogic.gdx.Screen screen, ServiceContainer container) Initialises the SnakeScreen with the provided game instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Disposes of resources used by the SnakeScreen.void
Clears the screen with a specific background color.void
render
(float delta) Renders the Snake game screen, including the grid and the apple.void
resize
(int width, int height) Resizes the elements on the screen including game elements, score board and exit buttonMethods inherited from class com.csse3200.game.screens.MiniGameScreen
exitGame, restartGame
Methods inherited from class com.csse3200.game.screens.PausableScreen
addOverlay, addSnakePopupOverlay, removeOverlay, rest, wake
Methods inherited from class com.badlogic.gdx.ScreenAdapter
hide, pause, resume, show
-
Constructor Details
-
SnakeScreen
Initialises the SnakeScreen with the provided game instance.- Parameters:
game
- The main game instance that controls the screen.
-
-
Method Details
-
render
public void render(float delta) Renders the Snake game screen, including the grid and the apple. This method is made for future use, so it will have a lot to change probably- Specified by:
render
in interfacecom.badlogic.gdx.Screen
- Overrides:
render
in classcom.badlogic.gdx.ScreenAdapter
- Parameters:
delta
- Time in seconds since the last frame.
-
drawBackground
public void drawBackground()Clears the screen with a specific background color. -
resize
public void resize(int width, int height) Resizes the elements on the screen including game elements, score board and exit button- Specified by:
resize
in interfacecom.badlogic.gdx.Screen
- Overrides:
resize
in classcom.badlogic.gdx.ScreenAdapter
- Parameters:
width
- the width to resize toheight
- the height to resize to
-
dispose
public void dispose()Disposes of resources used by the SnakeScreen. This includes the ShapeRenderer used for rendering the grid and apple.- Specified by:
dispose
in interfacecom.badlogic.gdx.Screen
- Overrides:
dispose
in classcom.badlogic.gdx.ScreenAdapter
-