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 intThe current level of the player.private intThe current index to use as the player's sprite.private booleanA variable to help with the animation.private booleanA variable to see if the player is swimming.private final intThe max score multiplier.private BufferedImageThe current player's sprite.private intThe 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 voidattack(int collidedEntity) Attempts to attack something.private voidChecks if the player is swimming.voidDraws the entity.voidDraws the health bar of the entity.voidDraws the player's hit cooldown.voidDraws the player's score/exp.voiddrawStatusBar(Graphics g, Color color, int value, int maxValue, int barIndex) Draws a scalable value bar for the player.intGets the current level of the player.Gets the current player's sprite.intgetScore()Gets the current score of the player.voidInitializes the base texture.private voidIncreases the player's score up with the points taken from the target.voidsetCurrentPlayerImage(Direction playerDir) Set the player's sprite and handles animation in the givenDirection.voidupdate()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:EntityInitializes the base texture.- Specified by:
initTexturein 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:EntityUpdates 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- theGraphicswhich 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:EntityDraws the health bar of the entity.- Specified by:
drawHealthBarin classEntity- Parameters:
g- theGraphicswhich is used to draw
-
drawScoreBar
Draws the player's score/exp.- Parameters:
g- theGraphicswhich is used to draw
-
drawHitCooldownBar
Draws the player's hit cooldown.- Parameters:
g- theGraphicswhich is used to draw
-
draw
Description copied from class:EntityDraws the entity.
-