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.ScreenMain 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 intbackgroundOffsetprotected Coursecourseprotected DragonBoatGamegameprotected booleanispausedprotected Lane[]lanesprotected Leaderboardleaderboardprotected Opponent[]opponentsprotected PauseMenupauseMenuprotected floatpenaltyprotected Playerplayerprotected ProgressBarprogressBarprotected com.badlogic.gdx.scenes.scene2d.Stagestageprotected booleanstartedprotected java.lang.String[]timesprotected floattotalDeltaTime
-
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 voiddispose()Disposes of the screen when it is no longer needed.voidhide()Overrides default hide() method to blankvoidpause()Pauses the gamevoidrender(float deltaTime)Rendering function for the game loop, handling all game logic and displaying graphics.voidresize(int width, int height)Resizes the game screen.voidresume()Resumes the gamevoidshow()Overrides default show() method to blankvoidtogglePause()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:
renderin 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:
resizein 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:
pausein interfacecom.badlogic.gdx.Screen
-
resume
public void resume()
Resumes the game- Specified by:
resumein interfacecom.badlogic.gdx.Screen
-
dispose
public void dispose()
Disposes of the screen when it is no longer needed.- Specified by:
disposein interfacecom.badlogic.gdx.Screen
-
hide
public void hide()
Overrides default hide() method to blank- Specified by:
hidein interfacecom.badlogic.gdx.Screen
-
show
public void show()
Overrides default show() method to blank- Specified by:
showin interfacecom.badlogic.gdx.Screen
-
-