java.lang.Object
dev.aurumbyte.sypherengine.components.Component
dev.aurumbyte.sypherengine.components.AABB

public class AABB extends Component
Axis Aligned Bounding Box collider, also a component that can be added.
Since:
v0.3.0
Author:
AurumByte
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    javafx.geometry.Rectangle2D
    The base JavaFX class, the core of the AABB functionality
    (package private) float
    Width and height of the AABB
    (package private) Entity
    The parent entity of the AABB
    Position of the AABB
    (package private) boolean
    Field to show whether the AABB is in debug mode or not
    (package private) float
    Width and height of the AABB

    Fields inherited from class dev.aurumbyte.sypherengine.components.Component

    componentTag
  • Constructor Summary

    Constructors
    Constructor
    Description
    AABB(Entity parent)
    A new AABB, attached to a parent
    AABB(Vector2 position, float width, float height)
    A new AABB, with a specified location, width and height
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    check if the current entity, over which the AABB acts as a collider, collides with another entity
    boolean
    check if anything is inside the current entity
    boolean
    check if the current entity, over which the AABB acts as a collider, is inside another entity
    boolean
    check if the current x and y coords of the point lies within the boundaries of the current entity
    void
    Render the AABB borders, if the AABB is in debug mode
    void
    setBoundingBox(Vector2 position, int width, int height)
    Setting the AABB to a specific location, width and height
    void
    setIfDebug(boolean shouldDebug)
    Toggle the debug mode of the AABB
    void
    update(float deltaTime)
    Updating the AABB

    Methods inherited from class dev.aurumbyte.sypherengine.components.Component

    getAABBComponent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • position

      public Vector2 position
      Position of the AABB
    • width

      float width
      Width and height of the AABB
    • height

      float height
      Width and height of the AABB
    • shouldDebug

      boolean shouldDebug
      Field to show whether the AABB is in debug mode or not
    • boundingBox

      public javafx.geometry.Rectangle2D boundingBox
      The base JavaFX class, the core of the AABB functionality
    • parent

      Entity parent
      The parent entity of the AABB
  • Constructor Details

    • AABB

      public AABB(Entity parent)

      A new AABB, attached to a parent

      Parameters:
      parent - The entity to which the AABB acts as a collider
      Since:
      0.3.0
    • AABB

      public AABB(Vector2 position, float width, float height)

      A new AABB, with a specified location, width and height

      Parameters:
      position - The position of the AABB
      width - The width of the AABB
      height - The height of the AABB
      Since:
      0.3.0
  • Method Details

    • update

      public void update(float deltaTime)

      Updating the AABB

      Specified by:
      update in class Component
      Parameters:
      deltaTime - DeltaTime, the duration taken to update a frame
      Since:
      0.3.0
    • render

      public void render(SypherEngine engine)

      Render the AABB borders, if the AABB is in debug mode

      Specified by:
      render in class Component
      Parameters:
      engine - the base engine, which runs the game
      Since:
      0.3.0
    • isCollidingWith

      public boolean isCollidingWith(Entity other)

      check if the current entity, over which the AABB acts as a collider, collides with another entity

      Parameters:
      other - the other entity
      Since:
      0.3.0
    • isInsideOf

      public boolean isInsideOf(Entity other)

      check if the current entity, over which the AABB acts as a collider, is inside another entity

      Parameters:
      other - the entity, in which the current entity may or may not be inside of
      Since:
      0.3.0
    • isEntityInside

      public boolean isEntityInside(Entity other)

      check if anything is inside the current entity

      Parameters:
      other - the entity which may or may not be inside the current entity
      Since:
      0.3.0
    • isPointInsideOf

      public boolean isPointInsideOf(Vector2 point)

      check if the current x and y coords of the point lies within the boundaries of the current entity

      Parameters:
      point - the coords to be checked
      Since:
      0.3.0
    • setIfDebug

      public void setIfDebug(boolean shouldDebug)

      Toggle the debug mode of the AABB

      Parameters:
      shouldDebug - value for the debug field.
      Since:
      0.3.0
    • setBoundingBox

      public void setBoundingBox(Vector2 position, int width, int height)

      Setting the AABB to a specific location, width and height

      Parameters:
      position - The position of the AABB
      width - The width of the AABB
      height - The height of the AABB
      Since:
      0.3.0