Class InanimateTrigger

All Implemented Interfaces:
Collidable
Direct Known Subclasses:
EndTrigger

public class InanimateTrigger extends Inanimate
This is the default implementation of an inanimate trigger in the game.
  • Constructor Details

    • InanimateTrigger

      public InanimateTrigger(Vec pos, Vec size)
      Create the trigger.
      Parameters:
      pos - the position
      size - the size
  • Method Details

    • createTrigger

      public static void createTrigger(Vec pos, Vec size, Runnable onPerform)
      Utility function for easy use with lambdas.
      Parameters:
      pos - the position
      size - the size
      onPerform - perform()
    • 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 Inanimate
      Parameters:
      f - the GameGrid that represents the games field and supplies primitive drawing operations.
    • 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 Inanimate
      Parameters:
      element - the GameElement that collided with this GameElement
      dir - the Direction this GameElement has been collided from.
    • perform

      public void perform()
      Perform trigger-action.