Class GameScreen

  • All Implemented Interfaces:
    com.badlogic.gdx.Screen

    public class GameScreen
    extends java.lang.Object
    implements com.badlogic.gdx.Screen
    Main Game Screen class for Dragon Boat Game. This is the main game loop, handling all the game logic and rendering.
    • Field Detail

      • player

        protected final Player player
      • course

        protected final Course course
      • lanes

        protected final Lane[] lanes
      • opponents

        protected final Opponent[] opponents
      • times

        protected java.lang.String[] times
      • started

        protected boolean started
      • ispaused

        protected boolean ispaused
      • stage

        protected com.badlogic.gdx.scenes.scene2d.Stage stage
      • backgroundOffset

        protected int backgroundOffset
      • totalDeltaTime

        protected float totalDeltaTime
    • Constructor Detail

      • GameScreen

        public GameScreen​(DragonBoatGame game)
        Sets up everything needed for a race to take place.
        Parameters:
        game - Represents the initial state of DragonBoatGame.
      • GameScreen

        public GameScreen​(DragonBoatGame game,
                          boolean loaded)
        Sets up everything needed for a race to take place.
        Parameters:
        game - Represents the initial state of DragonBoatGame.
        loaded - Represents whether the game has been loaded from a save or not.
    • Method Detail

      • render

        public void render​(float deltaTime)

        Rendering function for the game loop, handling all game logic and displaying graphics.

        GAME LOOP

        - Spawns any Obstacles that need spawning.

        - Update Player and Opponent positions.

        - Check for collisions with Obstacles.

        - Display Background and Obstacles

        - Update Obstacle positions.

        - Display Player, Player UI and Opponents.

        - Display Progress Bar and checks which boats have finished.

        - Display Player timer.

        - Checks if all boats have finished, and displays a Leaderboard if so.

        Specified by:
        render in interface com.badlogic.gdx.Screen
        Parameters:
        deltaTime - Time passed since render function was last run.
      • resize

        public void resize​(int width,
                           int height)
        Resizes the game screen.
        Specified by:
        resize in interface com.badlogic.gdx.Screen
        Parameters:
        width - Width of the screen.
        height - Height of the screen.
      • togglePause

        public void togglePause()
        Toggles the current pause state
      • pause

        public void pause()
        Pauses the game
        Specified by:
        pause in interface com.badlogic.gdx.Screen
      • resume

        public void resume()
        Resumes the game
        Specified by:
        resume in interface com.badlogic.gdx.Screen
      • dispose

        public void dispose()
        Disposes of the screen when it is no longer needed.
        Specified by:
        dispose in interface com.badlogic.gdx.Screen
      • hide

        public void hide()
        Overrides default hide() method to blank
        Specified by:
        hide in interface com.badlogic.gdx.Screen
      • show

        public void show()
        Overrides default show() method to blank
        Specified by:
        show in interface com.badlogic.gdx.Screen