Class GameScreen

java.lang.Object
com.skloch.game.GameScreen
All Implemented Interfaces:
com.badlogic.gdx.Screen

public class GameScreen extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    final 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
    Constructor
    Description
    GameScreen(HustleGame game, int avatarChoice)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds an amount of recreational hours to the total amount for the current day
    void
    addSleptHours(int hours)
     
    void
    addStudyHours(int hours)
    Adds an amount of hours studied to the total hours studied
    void
    decreaseEnergy(int energy)
    Decreases the player's energy by a certain amount
    void
    Disposes of certain elements, called when the game is closed
    void
    DEBUG - Draws the player's 3 hitboxes Uncomment use at the bottom of render to use
    formatTime(int seconds)
    Takes a time in seconds and formats it a time in the format HH:MMam/pm
    void
    Ends the game, called at the end of the 7th day, switches to a screen that displays a score
    int
     
     
    float
     
    boolean
     
     
    void
     
    com.badlogic.gdx.InputAdapter
    Generates an InputAdapter to handle game specific keyboard inputs
    void
    passTime(float delta)
    Add a number of seconds to the time elapsed in the day
    void
     
    void
    render(float delta)
    Renders the player, updates sound, renders the map and updates any UI elements Called every frame
    void
    resize(int width, int height)
     
    void
    Called when switching back to this gameScreen
    void
    setEnergy(int energy)
    Sets the player's energy level and updates the onscreen bar
    void
    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 uiStage
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • game

      final HustleGame 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

      public Player 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

      private EventManager 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

      public DialogueBox dialogueBox
    • blackScreen

      public final com.badlogic.gdx.scenes.scene2d.ui.Image blackScreen
    • sleeping

      private boolean sleeping
  • Constructor Details

    • GameScreen

      public GameScreen(HustleGame game, int avatarChoice)
      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 interface com.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 interface com.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 interface com.badlogic.gdx.Screen
    • pause

      public void pause()
      Specified by:
      pause in interface com.badlogic.gdx.Screen
    • resume

      public void resume()
      Called when switching back to this gameScreen
      Specified by:
      resume in interface com.badlogic.gdx.Screen
    • hide

      public void hide()
      Specified by:
      hide in interface com.badlogic.gdx.Screen
    • dispose

      public void dispose()
      Disposes of certain elements, called when the game is closed
      Specified by:
      dispose in interface com.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

      public String formatTime(int seconds)
      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

      public String getMeal()
      Returns:
      Returns 'breakfast', 'lunch' or 'dinner' depending on the time of day
    • getWakeUpMessage

      public String 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