Package com.dicycat.kroy.screens
Class GameScreen
- java.lang.Object
-
- com.dicycat.kroy.screens.GameScreen
-
- All Implemented Interfaces:
com.badlogic.gdx.Screen
public class GameScreen extends java.lang.Object implements com.badlogic.gdx.Screen
Contains the main game logic- Author:
- Riju De, lnt20
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GameScreen.GameScreenState
-
Field Summary
Fields Modifier and Type Field Description Kroy
game
static TiledGameMap
gameMap
float
gameTimer
static java.lang.Boolean
showDebug
GameScreen.GameScreenState
state
GameTextures
textures
-
Constructor Summary
Constructors Constructor Description GameScreen(Kroy _game, int truckNum)
-
Method Summary
Modifier and Type Method Description void
addFortress()
Add one fortress to the countvoid
addGameObject(GameObject gameObject)
Add a game object next framevoid
dispose()
void
DrawCircle(com.badlogic.gdx.math.Vector2 position, float radius, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug circle (outline)void
DrawLine(com.badlogic.gdx.math.Vector2 start, com.badlogic.gdx.math.Vector2 end, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug linevoid
DrawRect(com.badlogic.gdx.math.Vector2 bottomLeft, com.badlogic.gdx.math.Vector2 dimensions, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug rectangle (outline)int
fortressesLeft()
How many fortresses are left?void
gameOver(boolean won)
Switch to the game over screenGameObject
getGameObject(int index)
java.util.List<GameObject>
getGameObjects()
HUD
getHud()
int
getLives()
FireTruck
getPlayer()
Allows external classes to access the playercom.badlogic.gdx.math.Vector2
getSpawnPosition()
void
hide()
void
pause()
void
removeFortress()
Remove one fortress to the countvoid
render(float delta)
Called every framevoid
resize(int width, int height)
void
respawn()
Respawns the player at the spawn position and updates the HUDvoid
resume()
void
setGameState(GameScreen.GameScreenState s)
void
show()
Screen first shownvoid
updateCamera()
Updates the position of the camera to have the truck centrevoid
updateLives()
-
-
-
Field Detail
-
game
public Kroy game
-
textures
public GameTextures textures
-
showDebug
public static java.lang.Boolean showDebug
-
gameTimer
public float gameTimer
-
state
public GameScreen.GameScreenState state
-
gameMap
public static TiledGameMap gameMap
-
-
Constructor Detail
-
GameScreen
public GameScreen(Kroy _game, int truckNum)
- Parameters:
_game
-truckNum
-
-
-
Method Detail
-
show
public void show()
Screen first shown- Specified by:
show
in interfacecom.badlogic.gdx.Screen
-
render
public void render(float delta)
Called every frame- Specified by:
render
in interfacecom.badlogic.gdx.Screen
-
addGameObject
public void addGameObject(GameObject gameObject)
Add a game object next frame- Parameters:
gameObject
- gameObject to be added
-
getPlayer
public FireTruck getPlayer()
Allows external classes to access the player- Returns:
- player
-
DrawLine
public void DrawLine(com.badlogic.gdx.math.Vector2 start, com.badlogic.gdx.math.Vector2 end, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug line- Parameters:
start
- Start of the lineend
- End of the linelineWidth
- Width of the linecolour
- Colour of the line
-
DrawCircle
public void DrawCircle(com.badlogic.gdx.math.Vector2 position, float radius, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug circle (outline)- Parameters:
position
- Centre of the circleradius
- Radius of the circlelineWidth
- Width of the outlinecolour
- Colour of the line
-
DrawRect
public void DrawRect(com.badlogic.gdx.math.Vector2 bottomLeft, com.badlogic.gdx.math.Vector2 dimensions, int lineWidth, com.badlogic.gdx.graphics.Color colour)
Draw a debug rectangle (outline)- Parameters:
bottomLeft
- Bottom left point of the rectangledimensions
- Dimensions of the rectangle (Width, Length)lineWidth
- Width of the outlinecolour
- Colour of the line
-
updateCamera
public void updateCamera()
Updates the position of the camera to have the truck centre
-
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
-
dispose
public void dispose()
- Specified by:
dispose
in interfacecom.badlogic.gdx.Screen
-
setGameState
public void setGameState(GameScreen.GameScreenState s)
- Parameters:
s
-
-
getGameObject
public GameObject getGameObject(int index)
- Parameters:
index
-- Returns:
-
getGameObjects
public java.util.List<GameObject> getGameObjects()
- Returns:
-
getLives
public int getLives()
-
addFortress
public void addFortress()
Add one fortress to the count
-
removeFortress
public void removeFortress()
Remove one fortress to the count
-
fortressesLeft
public int fortressesLeft()
How many fortresses are left?- Returns:
- Number of fortresses remaining
-
gameOver
public void gameOver(boolean won)
Switch to the game over screen- Parameters:
won
- Did the player reach the win state?
-
updateLives
public void updateLives()
-
respawn
public void respawn()
Respawns the player at the spawn position and updates the HUD
-
getHud
public HUD getHud()
-
getSpawnPosition
public com.badlogic.gdx.math.Vector2 getSpawnPosition()
-
-