Class Pickup

All Implemented Interfaces:
Collidable
Direct Known Subclasses:
Coin, Life

@Group public abstract class Pickup extends Entity
This class is the parent class of all Pickups in the game.
  • Constructor Details

    • Pickup

      protected Pickup()
      Prototype constructor.
    • Pickup

      protected Pickup(Vec startPos, Vec vel, Vec size)
      Create a pickup.
      Parameters:
      startPos - the start pos
      vel - the start velocity
      size - the size
  • Method Details

    • getPrototypes

      public static Set<? extends GameElement> getPrototypes()
      Load all Pickups.
      Returns:
      a set of pickups
      See Also:
    • create

      public abstract Pickup create(Vec startPos, String... options)
      Description copied from class: GameElement

      Stub Factory method that every GameElement must implement in order to being able to be instantiated dynamically by the level creation.

      A startPos must be supplied to position the new GameElement right.

      Also, an array of modifiers that the extending GameElement can define and use is supplied. These are used make level creation able to determine the GameElements behavior. Note: the modifiers are not checked in syntax, so it must be thoroughly checked.

      Overrides:
      create in class GameElement
      Parameters:
      startPos - the initial position of the new GameElement.
      options - optional parameters that may determine additional behavior of the GameElement.
      Returns:
      the newly created GameElement.
    • perform

      public abstract void perform(GameElement collector)
      Template method that should be overwritten in concrete Pickups to add the action that is performed upon being collected by the Player.
      Parameters:
      collector - the GameElement which collects this Pickup
    • reactToCollision

      public final void reactToCollision(GameElement element, Direction dir)
      Description copied from interface: Collidable

      Notification that this GameElement has been collided with from another GameElement element from the given direction dir.

      Can be overwritten for defining an optional reaction that the GameElement performs on the other GameElement and/or itself upon collision.

      Specified by:
      reactToCollision in interface Collidable
      Overrides:
      reactToCollision in class GameElement
      Parameters:
      element - the GameElement that collided with this GameElement
      dir - the Direction this GameElement has been collided from.
    • innerLogicLoop

      protected void innerLogicLoop()
      Description copied from class: Entity
      This method will calculate the next position of the Entity depending on the velocity.
      Overrides:
      innerLogicLoop in class Entity