Class SnakeScreen

java.lang.Object
com.badlogic.gdx.ScreenAdapter
All Implemented Interfaces:
com.badlogic.gdx.Screen

public class SnakeScreen extends MiniGameScreen
Represents the screen for the Snake game. Handles the rendering of the game components.
  • Constructor Details

    • SnakeScreen

      public SnakeScreen(GdxGame game, com.badlogic.gdx.Screen screen, ServiceContainer container)
      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 interface com.badlogic.gdx.Screen
      Overrides:
      render in class com.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 interface com.badlogic.gdx.Screen
      Overrides:
      resize in class com.badlogic.gdx.ScreenAdapter
      Parameters:
      width - the width to resize to
      height - 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 interface com.badlogic.gdx.Screen
      Overrides:
      dispose in class com.badlogic.gdx.ScreenAdapter