Class Player
java.lang.Object
rekit.logic.gameelements.GameElement
rekit.logic.gameelements.entities.Entity
rekit.logic.gameelements.entities.StateEntity
rekit.logic.gameelements.entities.Player
- All Implemented Interfaces:
org.fuchss.configuration.Configurable
,CameraTarget
,Collidable
@SetterInfo(res="conf/player")
public final class Player
extends StateEntity
implements CameraTarget, org.fuchss.configuration.Configurable
The (maybe) most important
The Player (most likely you).
Entity
of the Game:The Player (most likely you).
- Author:
- Dominik Fuchss, Angelo Aracri
-
Nested Class Summary
Nested classes/interfaces inherited from interface rekit.logic.Collidable
Collidable.Optional
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic float
The default camera offset for a player.static float
The player's bottom boost (used when colliding from bottom).static float
The player's jump boost.static long
The player's maximum jump time in millis.static float
The player's boost upon jumping on an enemy.static int
The player's default amount of lives.static float
The player's stop acceleration.static float
The player's walk acceleration.static float
The player's walk max speed.Fields inherited from class rekit.logic.gameelements.entities.Entity
invincibility, lives
Fields inherited from class rekit.logic.gameelements.GameElement
deleteMe, deltaTime, team, visible
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDamage
(int damage) Optional reaction to a collision.void
addPoints
(int points) Adds points to the Players score.void
collidedWithSolid
(Frame collision, Direction dir) This implementation will ensure that no entity is able to fall through the ground or into another Object.float
Get the current camera offset.Get the current direction.int
Getter for the collected Points of the Player.void
init()
(Re-)Initialize the GameElement.void
Template method that will be called periodically after being added to aIScene
.void
Behavior after this GameElement hit an enemyvoid
Reset current camera offset.void
setInvincible
(long millis) Set Player invincible for a time.void
setTemporaryAppearance
(Consumer<GameGrid> r, long millis) Set a temporary renderer for the Player.Methods inherited from class rekit.logic.gameelements.entities.StateEntity
getEntityState, innerLogicLoop, setEntityState
Methods inherited from class rekit.logic.gameelements.entities.Entity
getLives, isVisible, logicLoop, setLives
Methods inherited from class rekit.logic.gameelements.GameElement
checkCollision, create, destroy, getDeleteMe, getFrame, getPos, getScene, getSize, getTeam, getVel, getZ, getZHint, isAddableToGroup, reactToCollision, render, setPos, setScene, setSize, setVel
-
Field Details
-
CAMERA_OFFSET
public static float CAMERA_OFFSETThe default camera offset for a player. -
WALK_ACCEL
public static float WALK_ACCELThe player's walk acceleration. -
STOP_ACCEL
public static float STOP_ACCELThe player's stop acceleration. -
WALK_MAX_SPEED
public static float WALK_MAX_SPEEDThe player's walk max speed. -
JUMP_BOOST
public static float JUMP_BOOSTThe player's jump boost. -
KILL_BOOST
public static float KILL_BOOSTThe player's boost upon jumping on an enemy. -
JUMP_TIME
public static long JUMP_TIMEThe player's maximum jump time in millis. -
FLOOR_BOOST
public static float FLOOR_BOOSTThe player's bottom boost (used when colliding from bottom). -
LIVES
public static int LIVESThe player's default amount of lives.
-
-
Constructor Details
-
Player
Create a player by start position.- Parameters:
startPos
- the start position
-
-
Method Details
-
init
public void init()Description copied from class:GameElement
(Re-)Initialize the GameElement.- Overrides:
init
in classGameElement
-
internalRender
Description copied from class:GameElement
Template method that will be called periodically after being added to a
IScene
. Must be as performant as possible to keep the FPS low, since it will be called in every render-loop.Should be overwritten in sub classes for custom visualization using the
GameGrid
.- Overrides:
internalRender
in classGameElement
- Parameters:
f
- theGameGrid
that represents the games field and supplies primitive drawing operations.
-
collidedWithSolid
Description copied from class:Entity
This implementation will ensure that no entity is able to fall through the ground or into another Object.- Specified by:
collidedWithSolid
in interfaceCollidable
- Overrides:
collidedWithSolid
in classStateEntity
- Parameters:
collision
- the Frame of the GameElement that was collided ondir
- the direction of this GameElement where the collision took place
-
addDamage
public void addDamage(int damage) Description copied from interface:Collidable
Optional reaction to a collision. Removes lifes of the GameElement.- Specified by:
addDamage
in interfaceCollidable
- Overrides:
addDamage
in classEntity
- Parameters:
damage
- the amount of lifes to remove
-
setInvincible
public void setInvincible(long millis) Set Player invincible for a time.- Parameters:
millis
- the millis
-
resetCameraOffset
public void resetCameraOffset()Reset current camera offset. -
getCameraOffset
public float getCameraOffset()Description copied from interface:CameraTarget
Get the current camera offset.- Specified by:
getCameraOffset
in interfaceCameraTarget
- Returns:
- the current camera offset
-
setTemporaryAppearance
Set a temporary renderer for the Player.- Parameters:
r
- the renderermillis
- the time
-
getCurrentDirection
Get the current direction.- Returns:
- the current direction
-
addPoints
public void addPoints(int points) Adds points to the Players score.- Parameters:
points
- the points to add (or subtract, iff negative)
-
getPoints
public int getPoints()Getter for the collected Points of the Player.- Returns:
- the points of the Player
-
killBoost
public void killBoost()Description copied from class:GameElement
Behavior after this GameElement hit an enemy- Overrides:
killBoost
in classGameElement
-