Class 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 Entity of the Game:
The Player (most likely you).
Author:
Dominik Fuchss, Angelo Aracri
  • Field Details

    • CAMERA_OFFSET

      public static float CAMERA_OFFSET
      The default camera offset for a player.
    • WALK_ACCEL

      public static float WALK_ACCEL
      The player's walk acceleration.
    • STOP_ACCEL

      public static float STOP_ACCEL
      The player's stop acceleration.
    • WALK_MAX_SPEED

      public static float WALK_MAX_SPEED
      The player's walk max speed.
    • JUMP_BOOST

      public static float JUMP_BOOST
      The player's jump boost.
    • KILL_BOOST

      public static float KILL_BOOST
      The player's boost upon jumping on an enemy.
    • JUMP_TIME

      public static long JUMP_TIME
      The player's maximum jump time in millis.
    • FLOOR_BOOST

      public static float FLOOR_BOOST
      The player's bottom boost (used when colliding from bottom).
    • LIVES

      public static int LIVES
      The player's default amount of lives.
  • Constructor Details

    • Player

      public Player(Vec startPos)
      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 class GameElement
    • internalRender

      public void internalRender(GameGrid f)
      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 class GameElement
      Parameters:
      f - the GameGrid that represents the games field and supplies primitive drawing operations.
    • collidedWithSolid

      public void collidedWithSolid(Frame collision, Direction dir)
      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 interface Collidable
      Overrides:
      collidedWithSolid in class StateEntity
      Parameters:
      collision - the Frame of the GameElement that was collided on
      dir - 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 interface Collidable
      Overrides:
      addDamage in class Entity
      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 interface CameraTarget
      Returns:
      the current camera offset
    • setTemporaryAppearance

      public void setTemporaryAppearance(Consumer<GameGrid> r, long millis)
      Set a temporary renderer for the Player.
      Parameters:
      r - the renderer
      millis - the time
    • getCurrentDirection

      public Direction 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 class GameElement