Package dev.kyzel.game
Class Game
java.lang.Object
dev.kyzel.game.Game
- All Implemented Interfaces:
Runnable
The main game.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intThe x coordinate of the player on the screen.private intThe y coordinate of the player on the screen.TheEntitylist of the game.private GameStateThe currentGameState.private ThreadThe mainThreadfor the game.private booleanA variable to see if the game has HUD.private booleanA variable to see if the game has minimap.private booleanA variable to see if the game is paused.private MinimapTheMinimapof the game.private PlayerThePlayerof the game.private intA modified x offset of the camera to prevent showing the void.private intA modified y offset of the camera to prevent showing the void.private RendererTheRendererwhere the game will be drawn on.private intThe x offset of the camera.private intThe y offset of the camera.private TileManagerTheTileManagerof the game. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDraws the game.intgetCamX()Gets the x coordinate of the player on the screen.intgetCamY()Gets the y coordinate of the player on the screen.Gets theEntitylist of the game.Gets thePlayerof the game.intGets the modified x offset of the camera.intGets the modified y offset of the camera.intGets the x offset of the camera.intGets the y offset of the camera.Gets theTileManagerof the game.voidrun()Updates and redraws the game every 60 ticks.voidsetAttributes(int width, int height) Set the attributes of the game to match with the new width and height.voidSet the initial position for the player and camera.voidsetPlayerSceneX(int playerSceneX) Set the modified x offset of the camera to the given value.voidsetPlayerSceneY(int playerSceneY) Set the modified y offset of the camera to the given value.voidsetSceneX(int sceneX) Set the x offset of the camera to the given value.voidsetSceneY(int sceneY) Set the y offset of the camera to the given value.voidupdate()Update the game.
-
Field Details
-
gameState
The currentGameState. -
render
TheRendererwhere the game will be drawn on. -
tileManager
TheTileManagerof the game. -
minimap
TheMinimapof the game. -
isPausing
private boolean isPausingA variable to see if the game is paused. -
hasHUD
private boolean hasHUDA variable to see if the game has HUD. -
hasMinimap
private boolean hasMinimapA variable to see if the game has minimap. -
camX
private int camXThe x coordinate of the player on the screen. -
camY
private int camYThe y coordinate of the player on the screen. -
sceneX
private int sceneXThe x offset of the camera. -
sceneY
private int sceneYThe y offset of the camera. -
playerSceneX
private int playerSceneXA modified x offset of the camera to prevent showing the void. -
playerSceneY
private int playerSceneYA modified y offset of the camera to prevent showing the void. -
player
ThePlayerof the game. -
entityList
TheEntitylist of the game. -
gameThread
The mainThreadfor the game.
-
-
Constructor Details
-
Game
Creates a new game.- Parameters:
render- theRendererwhere 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 widthheight- the new height
-
getPlayer
Gets thePlayerof the game.- Returns:
- the
Playerof the game
-
getEntityList
Gets theEntitylist of the game.- Returns:
- the
Entitylist of the game
-
getTileManager
Gets theTileManagerof the game.- Returns:
- the
TileManagerof 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
Draws the game.- Parameters:
gameImageGraphics- theGraphicswhich is used to draw
-
update
public void update()Update the game. -
run
public void run()Updates and redraws the game every 60 ticks.
-