Package collider

Class CircleCollider

java.lang.Object
collider.Collider
collider.CircleCollider

public class CircleCollider extends Collider
Collider for round objects
  • Constructor Details

    • CircleCollider

      public CircleCollider(String id, GameObject o, double radius)
      Constructor which sets the radius to be respected for collisions.
      Parameters:
      id - String unique name for the collider instance
      o - GameObject it belongs to
      radius - radius in pixels to use as a size
  • Method Details

    • toString

      public String toString()
      simple concatenation of all attributes (x,y,r)
      Overrides:
      toString in class Collider
    • checkCollisionCircCirc

      public boolean checkCollisionCircCirc(Collider _c2) throws Exception
      calculates the collission of this with other collider
      Parameters:
      _c2 - the other collider
      Returns:
      true if a collision was detected
      Throws:
      Exception - in case the math operations are invalid (due to illegal values of x y or radius)
    • collidesWith

      public boolean collidesWith(Collider other)
      Description copied from class: Collider
      checks the collission with another collider instance.
      Specified by:
      collidesWith in class Collider
      Parameters:
      other - the instance to compare to
      Returns:
      true if the colliders collide (touch or overlap)