Class Entity

java.lang.Object
rekit.logic.gameelements.GameElement
rekit.logic.gameelements.entities.Entity
All Implemented Interfaces:
Collidable
Direct Known Subclasses:
Boss, Enemy, Pickup, StateEntity

public abstract class Entity extends GameElement
This class represents one of the most important GameElement-Type:
These are the moving GameElements, which can interact between each other, so as the Player, Enemies, Pickups, etc.
Author:
Dominik Fuchss, Angelo Aracri
  • Field Details

    • lives

      protected int lives
      The amount of lives the Entity has. Upon reaching 0 lives, he dies.
    • invincibility

      protected Timer invincibility
      This Timer defines invincibility of an Entity. (null --> not invincible)
  • Constructor Details

    • Entity

      protected Entity(Team team)
      Minimal Constructor by Team used for prototype constructors. The element will not be initialized
      Parameters:
      team - the team
    • Entity

      protected Entity(Vec startPos, Vec vel, Vec size, Team team)
      Constructor that initializes attributes and takes a start position.
      Parameters:
      startPos - the position this entity shall be in
      vel - the velocity
      size - the size
      team - the team
  • Method Details

    • addDamage

      public void addDamage(int damage)
      Description copied from interface: Collidable
      Optional reaction to a collision. Removes lifes of the GameElement.
      Parameters:
      damage - the amount of lifes to remove
    • setLives

      public final void setLives(int lives)
      Set current lives.
      Parameters:
      lives - the lives
    • getLives

      public final int getLives()
      Description copied from interface: Collidable
      Getter for the current lifes of the GameElement.
      Returns:
      the amount of lifes of the GameElement
    • logicLoop

      public final void logicLoop()
      Description copied from class: GameElement

      Template method that will be called periodically after being added to a IScene.

      Should be overwritten in sub classes for implementing custom logic, physics emulation, time-based actions, ...

      Overrides:
      logicLoop in class GameElement
    • innerLogicLoop

      protected void innerLogicLoop()
      This method will calculate the next position of the Entity depending on the velocity.
    • collidedWithSolid

      @Optional public void collidedWithSolid(Frame collision, Direction dir)
      This implementation will ensure that no entity is able to fall through the ground or into another Object.
      Parameters:
      collision - the Frame of the GameElement that was collided on
      dir - the direction of this GameElement where the collision took place
    • isVisible

      protected boolean isVisible()
      Description copied from class: GameElement
      Returns if the GameElement is currently supposed to be rendered or not.
      Overrides:
      isVisible in class GameElement
      Returns:
      true if the GameElement should be rendered, false otherwise.