Class MainGameScreen

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

    public class MainGameScreen
    extends java.lang.Object
    implements com.badlogic.gdx.Screen
    Represents the Main Game Screen where the game actually happens.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  MainGameScreen.State
      Giving names to game states.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ScrollingBackground background
      The background of the window.
      private int countDownRemaining
      The time left on the initial countdown.
      private java.lang.String countDownString
      The String being displayed in the countdown.
      private com.badlogic.gdx.graphics.g2d.BitmapFont font
      Font used for rendering to screen
      private DragonBoatRace game
      The game instance.
      private byte gameState
      What state the game is in, starts in COUNTDOWN.
      private com.badlogic.gdx.graphics.g2d.GlyphLayout layout
      GlyphLayout used for centering fonts
      private com.badlogic.gdx.graphics.FPSLogger logger
      Use to log the FPS for debugging.
      private PauseScreen pauseScreen
      The screen the user sees when the game is paused
      private Race race
      The race instance.
      private com.badlogic.gdx.utils.Timer timer
      Used to make sure the countdown happens at equal intervals.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void displayCountDown()
      Render the current status of the countdown.
      void dispose()  
      void hide()  
      void pause()  
      void render​(float deltaTime)
      Render the main game window.
      void resize​(int width, int height)  
      void restore()  
      void resume()  
      void save()  
      private void setPausedState()
      Check if game is being paused, if it is, gameState is set to PAUSED
      void show()
      Runs when the window first starts.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • timer

        private final com.badlogic.gdx.utils.Timer timer
        Used to make sure the countdown happens at equal intervals.
      • race

        private final Race race
        The race instance.
      • logger

        private final com.badlogic.gdx.graphics.FPSLogger logger
        Use to log the FPS for debugging.
      • layout

        private final com.badlogic.gdx.graphics.g2d.GlyphLayout layout
        GlyphLayout used for centering fonts
      • font

        private final com.badlogic.gdx.graphics.g2d.BitmapFont font
        Font used for rendering to screen
      • gameState

        private byte gameState
        What state the game is in, starts in COUNTDOWN. Can also be RUNNING or PAUSED.
      • countDownRemaining

        private int countDownRemaining
        The time left on the initial countdown.
      • countDownString

        private java.lang.String countDownString
        The String being displayed in the countdown.
      • pauseScreen

        private final PauseScreen pauseScreen
        The screen the user sees when the game is paused
    • Constructor Detail

      • MainGameScreen

        public MainGameScreen​(DragonBoatRace game,
                              BoatType boatChosen)
        Creates a new game screen with a game instance.
        Parameters:
        game - The game instance.
        boatChosen - The BoatType that the player chose.
    • Method Detail

      • show

        public void show()
        Runs when the window first starts. Runs the countdown starter.
        Specified by:
        show in interface com.badlogic.gdx.Screen
      • render

        public void render​(float deltaTime)
        Render the main game window. Includes rendering the background and the Race. Will switch to the pause screen if gameState is PAUSED
        Specified by:
        render in interface com.badlogic.gdx.Screen
        Parameters:
        deltaTime - The time since the last frame.
      • displayCountDown

        private void displayCountDown()
        Render the current status of the countdown.
      • resize

        public void resize​(int width,
                           int height)
        Specified by:
        resize in interface com.badlogic.gdx.Screen
      • pause

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

        public void resume()
        Specified by:
        resume in interface com.badlogic.gdx.Screen
      • hide

        public void hide()
        Specified by:
        hide in interface com.badlogic.gdx.Screen
      • setPausedState

        private void setPausedState()
        Check if game is being paused, if it is, gameState is set to PAUSED
      • dispose

        public void dispose()
        Specified by:
        dispose in interface com.badlogic.gdx.Screen
      • restore

        public void restore()
      • save

        public void save()