Package rekit.logic

Interface Collidable

All Known Implementing Classes:
BackgroundElement, Boss, Coin, DamageParticle, DefaultCoin, DynamicInanimate, EndTrigger, Enemy, Entity, GameElement, HeapElement, HeapElementCloud, HeapElementMountain, Inanimate, InanimateBox, InanimateDoor, InanimateFloor, InanimateTrigger, Life, Particle, Pickup, Player, StateEntity, TextParticle

public interface Collidable
Defines the interface that every GameElement that can collide must have.
Author:
Angelo Aracri
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static @interface 
    Methods which are annotated with this annotation, are optional methods for special behavior.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addDamage(int damage)
    Optional reaction to a collision.
    default void
    Optional reaction to a collision that can be invoked in other GameElements reactToCollision().
    default int
    Getter for the current lifes of the GameElement.
    default void
    Notification that this GameElement has been collided with from another GameElement element from the given direction dir.
  • Method Details

    • addDamage

      default void addDamage(int damage)
      Optional reaction to a collision. Removes lifes of the GameElement.
      Parameters:
      damage - the amount of lifes to remove
    • getLives

      default int getLives()
      Getter for the current lifes of the GameElement.
      Returns:
      the amount of lifes of the GameElement
    • collidedWithSolid

      @Optional default void collidedWithSolid(Frame collision, Direction dir)
      Optional reaction to a collision that can be invoked in other GameElements reactToCollision(). Notification that this GameElement has collided with another GameElement with the CollisionFrame collision from a given direction dir. Define optional reactions that the GameElement performs on itself upon collision.
      Parameters:
      collision - the Frame of the GameElement that was collided on
      dir - the direction of this GameElement where the collision took place
    • reactToCollision

      default void reactToCollision(GameElement element, Direction dir)

      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.

      Parameters:
      element - the GameElement that collided with this GameElement
      dir - the Direction this GameElement has been collided from.