Package com.dragonboatrace.screens
Class MainGameScreen
- java.lang.Object
-
- com.dragonboatrace.screens.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 screenprivate 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 fontsprivate 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 pausedprivate Race
race
The race instance.private com.badlogic.gdx.utils.Timer
timer
Used to make sure the countdown happens at equal intervals.
-
Constructor Summary
Constructors Constructor Description MainGameScreen(DragonBoatRace game, BoatType boatChosen)
Creates a new game screen with a game instance.
-
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 PAUSEDvoid
show()
Runs when the window first starts.
-
-
-
Field Detail
-
game
private final DragonBoatRace game
The game instance.
-
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.
-
background
private final ScrollingBackground background
The background of the window.
-
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
- TheBoatType
that the player chose.
-
-
Method Detail
-
show
public void show()
Runs when the window first starts. Runs the countdown starter.- Specified by:
show
in interfacecom.badlogic.gdx.Screen
-
render
public void render(float deltaTime)
Render the main game window. Includes rendering the background and theRace
. Will switch to the pause screen if gameState is PAUSED- Specified by:
render
in interfacecom.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 interfacecom.badlogic.gdx.Screen
-
pause
public void pause()
- Specified by:
pause
in interfacecom.badlogic.gdx.Screen
-
resume
public void resume()
- Specified by:
resume
in interfacecom.badlogic.gdx.Screen
-
hide
public void hide()
- Specified by:
hide
in interfacecom.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 interfacecom.badlogic.gdx.Screen
-
restore
public void restore()
-
save
public void save()
-
-