Package dev.kyzel.game.entity
Class Player
java.lang.Object
dev.kyzel.game.entity.Entity
dev.kyzel.game.entity.Player
- All Implemented Interfaces:
IAttackable
The player class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
The current level of the player.private int
The current index to use as the player's sprite.private boolean
A variable to help with the animation.private boolean
A variable to see if the player is swimming.private final int
The max score multiplier.private BufferedImage
The current player's sprite.private int
The current score of the player at the current level.Fields inherited from class dev.kyzel.game.entity.Entity
attackValue, basedSpeed, currentHealthValue, direction, game, healingCounter, hitTick, invincibleCounter, isCursed, knockbackCounter, maxHealingCounter, maxHealthValue, maxHitTick, maxInvincibleCounter, maxKnockbackCounter, previousDirection, render, solidArea, solidAreaDefaultX, solidAreaDefaultY, speed, spriteCounter, state, x, y
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
attack
(int collidedEntity) Attempts to attack something.private void
Checks if the player is swimming.void
Draws the entity.void
Draws the health bar of the entity.void
Draws the player's hit cooldown.void
Draws the player's score/exp.void
drawStatusBar
(Graphics g, Color color, int value, int maxValue, int barIndex) Draws a scalable value bar for the player.int
Gets the current level of the player.Gets the current player's sprite.int
getScore()
Gets the current score of the player.void
Initializes the base texture.private void
Increases the player's score up with the points taken from the target.void
setCurrentPlayerImage
(Direction playerDir) Set the player's sprite and handles animation in the givenDirection
.void
update()
Updates the entity.Methods inherited from class dev.kyzel.game.entity.Entity
collideWithEntity, collideWithPlayer, collideWithTile, cursed, getAttackValue, getDirection, getGame, getHealthValue, getInvincibleCounter, getKnockbackCounter, getMaxHealthValue, getPreviousDirection, getRender, getSolidArea, getSolidAreaDefaultX, getSolidAreaDefaultY, getSpeed, getSwimmingSpeed, getX, getY, healing, increaseImageIndex, inflictDamage, isAlive, isCursed, isDead, isInRange, knockback, setAttackValue, setDirection, setHealthValue, setInvincibleCounter, setKnockbackCounter, setMaxHealthValue, setPreviousDirection, setRender, setSpeed, setX, setY
-
Field Details
-
imageIndex
private int imageIndexThe current index to use as the player's sprite. -
playerImage
The current player's sprite. -
isSwimming
private boolean isSwimmingA variable to see if the player is swimming. -
isLeftLeg
private boolean isLeftLegA variable to help with the animation. -
currentLevel
private int currentLevelThe current level of the player. -
score
private int scoreThe current score of the player at the current level. -
maxScoreMultiplier
private final int maxScoreMultiplierThe max score multiplier.- See Also:
-
-
Constructor Details
-
Method Details
-
initTexture
public void initTexture()Description copied from class:Entity
Initializes the base texture.- Specified by:
initTexture
in classEntity
-
checkSwimming
private void checkSwimming()Checks if the player is swimming. -
scoreUp
Increases the player's score up with the points taken from the target.- Parameters:
target
- the target
-
attack
private void attack(int collidedEntity) Attempts to attack something.- Parameters:
collidedEntity
- the collided entity, -1 represents that there is no collided entity
-
update
public void update()Description copied from class:Entity
Updates the entity. -
getPlayerImage
Gets the current player's sprite.- Returns:
- the current player's sprite
-
getScore
public int getScore()Gets the current score of the player.- Returns:
- the current score of the player
-
getCurrentLevel
public int getCurrentLevel()Gets the current level of the player.- Returns:
- the current level of the player
-
setCurrentPlayerImage
Set the player's sprite and handles animation in the givenDirection
.- Parameters:
playerDir
- the givenDirection
-
drawStatusBar
Draws a scalable value bar for the player.- Parameters:
g
- theGraphics
which is used to drawcolor
- the color of the barvalue
- the current valuemaxValue
- the max valuebarIndex
- the index of the bar, which is used to determine the order of the bar
-
drawHealthBar
Description copied from class:Entity
Draws the health bar of the entity.- Specified by:
drawHealthBar
in classEntity
- Parameters:
g
- theGraphics
which is used to draw
-
drawScoreBar
Draws the player's score/exp.- Parameters:
g
- theGraphics
which is used to draw
-
drawHitCooldownBar
Draws the player's hit cooldown.- Parameters:
g
- theGraphics
which is used to draw
-
draw
Description copied from class:Entity
Draws the entity.
-