Class Game

java.lang.Object
dev.kyzel.game.Game
All Implemented Interfaces:
Runnable

public class Game extends Object implements Runnable
The main game.
  • Field Details

    • gameState

      private GameState gameState
      The current GameState.
    • render

      private Renderer render
      The Renderer where the game will be drawn on.
    • tileManager

      private TileManager tileManager
      The TileManager of the game.
    • minimap

      private Minimap minimap
      The Minimap of the game.
    • isPausing

      private boolean isPausing
      A variable to see if the game is paused.
    • hasHUD

      private boolean hasHUD
      A variable to see if the game has HUD.
    • hasMinimap

      private boolean hasMinimap
      A variable to see if the game has minimap.
    • camX

      private int camX
      The x coordinate of the player on the screen.
    • camY

      private int camY
      The y coordinate of the player on the screen.
    • sceneX

      private int sceneX
      The x offset of the camera.
    • sceneY

      private int sceneY
      The y offset of the camera.
    • playerSceneX

      private int playerSceneX
      A modified x offset of the camera to prevent showing the void.
    • playerSceneY

      private int playerSceneY
      A modified y offset of the camera to prevent showing the void.
    • player

      private Player player
      The Player of the game.
    • entityList

      private ArrayList<Entity> entityList
      The Entity list of the game.
    • gameThread

      private Thread gameThread
      The main Thread for the game.
  • Constructor Details

    • Game

      public Game(Renderer render)
      Creates a new game.
      Parameters:
      render - the Renderer where the game will be drawn on
  • Method Details

    • setPlayerInitialPosition

      public void setPlayerInitialPosition()
      Set the initial position for the player and camera.
    • setAttributes

      public void setAttributes(int width, int height)
      Set the attributes of the game to match with the new width and height.
      Parameters:
      width - the new width
      height - the new height
    • getPlayer

      public Player getPlayer()
      Gets the Player of the game.
      Returns:
      the Player of the game
    • getEntityList

      public ArrayList<Entity> getEntityList()
      Gets the Entity list of the game.
      Returns:
      the Entity list of the game
    • getTileManager

      public TileManager getTileManager()
      Gets the TileManager of the game.
      Returns:
      the TileManager of the game
    • getPlayerSceneX

      public int getPlayerSceneX()
      Gets the modified x offset of the camera.
      Returns:
      the modified x offset of the camera
    • setPlayerSceneX

      public void setPlayerSceneX(int playerSceneX)
      Set the modified x offset of the camera to the given value.
      Parameters:
      playerSceneX - the given value
    • getPlayerSceneY

      public int getPlayerSceneY()
      Gets the modified y offset of the camera.
      Returns:
      the modified y offset of the camera
    • setPlayerSceneY

      public void setPlayerSceneY(int playerSceneY)
      Set the modified y offset of the camera to the given value.
      Parameters:
      playerSceneY - the given value
    • getSceneX

      public int getSceneX()
      Gets the x offset of the camera.
      Returns:
      the x offset of the camera
    • setSceneX

      public void setSceneX(int sceneX)
      Set the x offset of the camera to the given value.
      Parameters:
      sceneX - the given value
    • getSceneY

      public int getSceneY()
      Gets the y offset of the camera.
      Returns:
      the y offset of the camera
    • setSceneY

      public void setSceneY(int sceneY)
      Set the y offset of the camera to the given value.
      Parameters:
      sceneY - the given value
    • getCamX

      public int getCamX()
      Gets the x coordinate of the player on the screen.
      Returns:
      the x coordinate of the player on the screen
    • getCamY

      public int getCamY()
      Gets the y coordinate of the player on the screen.
      Returns:
      the y coordinate of the player on the screen
    • draw

      public void draw(Graphics gameImageGraphics)
      Draws the game.
      Parameters:
      gameImageGraphics - the Graphics which is used to draw
    • update

      public void update()
      Update the game.
    • run

      public void run()
      Updates and redraws the game every 60 ticks.
      Specified by:
      run in interface Runnable