Package com.dragonboat.game
Class GameScreen
- java.lang.Object
-
- com.dragonboat.game.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 Summary
Fields Modifier and Type Field Description protected int
backgroundOffset
protected Course
course
protected DragonBoatGame
game
protected boolean
ispaused
protected Lane[]
lanes
protected Leaderboard
leaderboard
protected Opponent[]
opponents
protected PauseMenu
pauseMenu
protected float
penalty
protected Player
player
protected ProgressBar
progressBar
protected com.badlogic.gdx.scenes.scene2d.Stage
stage
protected boolean
started
protected java.lang.String[]
times
protected float
totalDeltaTime
-
Constructor Summary
Constructors Constructor Description GameScreen(DragonBoatGame game)
Sets up everything needed for a race to take place.GameScreen(DragonBoatGame game, boolean loaded)
Sets up everything needed for a race to take place.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Disposes of the screen when it is no longer needed.void
hide()
Overrides default hide() method to blankvoid
pause()
Pauses the gamevoid
render(float deltaTime)
Rendering function for the game loop, handling all game logic and displaying graphics.void
resize(int width, int height)
Resizes the game screen.void
resume()
Resumes the gamevoid
show()
Overrides default show() method to blankvoid
togglePause()
Toggles the current pause state
-
-
-
Field Detail
-
game
protected DragonBoatGame game
-
player
protected final Player player
-
course
protected final Course course
-
lanes
protected final Lane[] lanes
-
progressBar
protected final ProgressBar progressBar
-
leaderboard
protected final Leaderboard leaderboard
-
opponents
protected final Opponent[] opponents
-
times
protected java.lang.String[] times
-
started
protected boolean started
-
penalty
protected final float penalty
- See Also:
- Constant Field Values
-
ispaused
protected boolean ispaused
-
pauseMenu
protected PauseMenu pauseMenu
-
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 interfacecom.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 interfacecom.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 interfacecom.badlogic.gdx.Screen
-
resume
public void resume()
Resumes the game- Specified by:
resume
in interfacecom.badlogic.gdx.Screen
-
dispose
public void dispose()
Disposes of the screen when it is no longer needed.- Specified by:
dispose
in interfacecom.badlogic.gdx.Screen
-
hide
public void hide()
Overrides default hide() method to blank- Specified by:
hide
in interfacecom.badlogic.gdx.Screen
-
show
public void show()
Overrides default show() method to blank- Specified by:
show
in interfacecom.badlogic.gdx.Screen
-
-