Package com.skloch.game
Class GameScreen
java.lang.Object
com.skloch.game.GameScreen
- All Implemented Interfaces:
com.badlogic.gdx.Screen
Handles the majority of the game logic, rendering and user inputs of the game.
Responsible for rendering the player and the map, and calling events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal com.badlogic.gdx.scenes.scene2d.ui.Image
private com.badlogic.gdx.graphics.OrthographicCamera
private int
private com.badlogic.gdx.scenes.scene2d.ui.Label
private float
private int
private com.badlogic.gdx.scenes.scene2d.ui.Image
private com.badlogic.gdx.scenes.scene2d.ui.Window
private EventManager
(package private) final HustleGame
private int
private int
private int
protected com.badlogic.gdx.InputMultiplexer
private com.badlogic.gdx.scenes.scene2d.ui.Label
com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer
private boolean
private com.badlogic.gdx.scenes.scene2d.ui.Label
com.badlogic.gdx.scenes.scene2d.Stage
private com.badlogic.gdx.scenes.scene2d.ui.Table
private com.badlogic.gdx.utils.viewport.Viewport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRecreationalHours
(int hours) Adds an amount of recreational hours to the total amount for the current dayvoid
addSleptHours
(int hours) void
addStudyHours
(int hours) Adds an amount of hours studied to the total hours studiedvoid
decreaseEnergy
(int energy) Decreases the player's energy by a certain amountvoid
dispose()
Disposes of certain elements, called when the game is closedvoid
DEBUG - Draws the player's 3 hitboxes Uncomment use at the bottom of render to useformatTime
(int seconds) Takes a time in seconds and formats it a time in the format HH:MMam/pmvoid
GameOver()
Ends the game, called at the end of the 7th day, switches to a screen that displays a scoreint
getMeal()
float
boolean
void
hide()
com.badlogic.gdx.InputAdapter
Generates an InputAdapter to handle game specific keyboard inputsvoid
passTime
(float delta) Add a number of seconds to the time elapsed in the dayvoid
pause()
void
render
(float delta) Renders the player, updates sound, renders the map and updates any UI elements Called every framevoid
resize
(int width, int height) void
resume()
Called when switching back to this gameScreenvoid
setEnergy
(int energy) Sets the player's energy level and updates the onscreen barvoid
setSleeping
(boolean sleeping) void
setupEscapeMenu
(com.badlogic.gdx.scenes.scene2d.Stage interfaceStage) Configures everything needed to display the escape menu window when the player presses 'escape' Doesn't return anything as the variable escapeMenu is used to store the window Takes a table already added to the uiStagevoid
show()
-
Field Details
-
game
-
camera
private com.badlogic.gdx.graphics.OrthographicCamera camera -
energy
private int energy -
hoursStudied
private int hoursStudied -
hoursRecreational
private int hoursRecreational -
hoursSlept
private int hoursSlept -
daySeconds
private float daySeconds -
day
private int day -
timeLabel
private com.badlogic.gdx.scenes.scene2d.ui.Label timeLabel -
dayLabel
private com.badlogic.gdx.scenes.scene2d.ui.Label dayLabel -
player
-
escapeMenu
private com.badlogic.gdx.scenes.scene2d.ui.Window escapeMenu -
viewport
private com.badlogic.gdx.utils.viewport.Viewport viewport -
mapRenderer
public com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer mapRenderer -
uiStage
public com.badlogic.gdx.scenes.scene2d.Stage uiStage -
interactionLabel
private com.badlogic.gdx.scenes.scene2d.ui.Label interactionLabel -
eventManager
-
inputMultiplexer
protected com.badlogic.gdx.InputMultiplexer inputMultiplexer -
uiTable
private com.badlogic.gdx.scenes.scene2d.ui.Table uiTable -
energyBar
private com.badlogic.gdx.scenes.scene2d.ui.Image energyBar -
dialogueBox
-
blackScreen
public final com.badlogic.gdx.scenes.scene2d.ui.Image blackScreen -
sleeping
private boolean sleeping
-
-
Constructor Details
-
GameScreen
- Parameters:
game
- An instance of the class HustleGame containing variables that only need to be loaded or initialised once.avatarChoice
- Which avatar the player has picked, 0 for the more masculine avatar, 1 for the more feminine
-
-
Method Details
-
show
public void show()- Specified by:
show
in interfacecom.badlogic.gdx.Screen
-
render
public void render(float delta) Renders the player, updates sound, renders the map and updates any UI elements Called every frame- Specified by:
render
in interfacecom.badlogic.gdx.Screen
- Parameters:
delta
- The time in seconds since the last render.
-
setupEscapeMenu
public void setupEscapeMenu(com.badlogic.gdx.scenes.scene2d.Stage interfaceStage) Configures everything needed to display the escape menu window when the player presses 'escape' Doesn't return anything as the variable escapeMenu is used to store the window Takes a table already added to the uiStage- Parameters:
interfaceStage
- The stage that the escapeMenu should be added to
-
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()Called when switching back to this gameScreen- Specified by:
resume
in interfacecom.badlogic.gdx.Screen
-
hide
public void hide()- Specified by:
hide
in interfacecom.badlogic.gdx.Screen
-
dispose
public void dispose()Disposes of certain elements, called when the game is closed- Specified by:
dispose
in interfacecom.badlogic.gdx.Screen
-
drawHitboxes
public void drawHitboxes()DEBUG - Draws the player's 3 hitboxes Uncomment use at the bottom of render to use -
passTime
public void passTime(float delta) Add a number of seconds to the time elapsed in the day- Parameters:
delta
- The time in seconds to add
-
formatTime
Takes a time in seconds and formats it a time in the format HH:MMam/pm- Parameters:
seconds
- The seconds elapsed in a day- Returns:
- A formatted time on a 12 hour clock
-
makeInputAdapter
public com.badlogic.gdx.InputAdapter makeInputAdapter()Generates an InputAdapter to handle game specific keyboard inputs- Returns:
- An InputAdapter for keyboard inputs
-
setEnergy
public void setEnergy(int energy) Sets the player's energy level and updates the onscreen bar- Parameters:
energy
- An int between 0 and 100
-
getEnergy
public int getEnergy()- Returns:
- The player's energy out of 100
-
decreaseEnergy
public void decreaseEnergy(int energy) Decreases the player's energy by a certain amount- Parameters:
energy
- The energy to decrement
-
addStudyHours
public void addStudyHours(int hours) Adds an amount of hours studied to the total hours studied- Parameters:
hours
- The amount of hours to add
-
addRecreationalHours
public void addRecreationalHours(int hours) Adds an amount of recreational hours to the total amount for the current day- Parameters:
hours
- The amount of hours to add
-
getMeal
- Returns:
- Returns 'breakfast', 'lunch' or 'dinner' depending on the time of day
-
getWakeUpMessage
- Returns:
- A wake up message based on the time left until the exam
-
setSleeping
public void setSleeping(boolean sleeping) - Parameters:
sleeping
- Sets the value of sleeping
-
getSleeping
public boolean getSleeping()- Returns:
- true if the player is sleeping
-
addSleptHours
public void addSleptHours(int hours) - Parameters:
hours
- Add this amount of hours to the total hours slept
-
getSeconds
public float getSeconds()- Returns:
- The number of seconds elapsed in the day
-
GameOver
public void GameOver()Ends the game, called at the end of the 7th day, switches to a screen that displays a score
-