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 int
The x coordinate of the player on the screen.private int
The y coordinate of the player on the screen.TheEntity
list of the game.private GameState
The currentGameState
.private Thread
The mainThread
for the game.private boolean
A variable to see if the game has HUD.private boolean
A variable to see if the game has minimap.private boolean
A variable to see if the game is paused.private Minimap
TheMinimap
of the game.private Player
ThePlayer
of the game.private int
A modified x offset of the camera to prevent showing the void.private int
A modified y offset of the camera to prevent showing the void.private Renderer
TheRenderer
where the game will be drawn on.private int
The x offset of the camera.private int
The y offset of the camera.private TileManager
TheTileManager
of the game. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Draws the game.int
getCamX()
Gets the x coordinate of the player on the screen.int
getCamY()
Gets the y coordinate of the player on the screen.Gets theEntity
list of the game.Gets thePlayer
of the game.int
Gets the modified x offset of the camera.int
Gets the modified y offset of the camera.int
Gets the x offset of the camera.int
Gets the y offset of the camera.Gets theTileManager
of the game.void
run()
Updates and redraws the game every 60 ticks.void
setAttributes
(int width, int height) Set the attributes of the game to match with the new width and height.void
Set the initial position for the player and camera.void
setPlayerSceneX
(int playerSceneX) Set the modified x offset of the camera to the given value.void
setPlayerSceneY
(int playerSceneY) Set the modified y offset of the camera to the given value.void
setSceneX
(int sceneX) Set the x offset of the camera to the given value.void
setSceneY
(int sceneY) Set the y offset of the camera to the given value.void
update()
Update the game.
-
Field Details
-
gameState
The currentGameState
. -
render
TheRenderer
where the game will be drawn on. -
tileManager
TheTileManager
of the game. -
minimap
TheMinimap
of 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
ThePlayer
of the game. -
entityList
TheEntity
list of the game. -
gameThread
The mainThread
for the game.
-
-
Constructor Details
-
Game
Creates a new game.- Parameters:
render
- theRenderer
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 widthheight
- the new height
-
getPlayer
Gets thePlayer
of the game.- Returns:
- the
Player
of the game
-
getEntityList
Gets theEntity
list of the game.- Returns:
- the
Entity
list of the game
-
getTileManager
Gets theTileManager
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
Draws the game.- Parameters:
gameImageGraphics
- theGraphics
which is used to draw
-
update
public void update()Update the game. -
run
public void run()Updates and redraws the game every 60 ticks.
-