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 floatThe default camera offset for a player.static floatThe player's bottom boost (used when colliding from bottom).static floatThe player's jump boost.static longThe player's maximum jump time in millis.static floatThe player's boost upon jumping on an enemy.static intThe player's default amount of lives.static floatThe player's stop acceleration.static floatThe player's walk acceleration.static floatThe player's walk max speed.Fields inherited from class rekit.logic.gameelements.entities.Entity
invincibility, livesFields inherited from class rekit.logic.gameelements.GameElement
deleteMe, deltaTime, team, visible -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDamage(int damage) Optional reaction to a collision.voidaddPoints(int points) Adds points to the Players score.voidcollidedWithSolid(Frame collision, Direction dir) This implementation will ensure that no entity is able to fall through the ground or into another Object.floatGet the current camera offset.Get the current direction.intGetter for the collected Points of the Player.voidinit()(Re-)Initialize the GameElement.voidTemplate method that will be called periodically after being added to aIScene.voidBehavior after this GameElement hit an enemyvoidReset current camera offset.voidsetInvincible(long millis) Set Player invincible for a time.voidsetTemporaryAppearance(Consumer<GameGrid> r, long millis) Set a temporary renderer for the Player.Methods inherited from class rekit.logic.gameelements.entities.StateEntity
getEntityState, innerLogicLoop, setEntityStateMethods inherited from class rekit.logic.gameelements.entities.Entity
getLives, isVisible, logicLoop, setLivesMethods 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:
initin classGameElement
-
internalRender
Description copied from class:GameElementTemplate 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:
internalRenderin classGameElement- Parameters:
f- theGameGridthat represents the games field and supplies primitive drawing operations.
-
collidedWithSolid
Description copied from class:EntityThis implementation will ensure that no entity is able to fall through the ground or into another Object.- Specified by:
collidedWithSolidin interfaceCollidable- Overrides:
collidedWithSolidin 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:CollidableOptional reaction to a collision. Removes lifes of the GameElement.- Specified by:
addDamagein interfaceCollidable- Overrides:
addDamagein 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:CameraTargetGet the current camera offset.- Specified by:
getCameraOffsetin 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:GameElementBehavior after this GameElement hit an enemy- Overrides:
killBoostin classGameElement
-