vooga.engine.collision
Class CollisionManager

java.lang.Object
  extended by vooga.engine.collision.CollisionManager
Direct Known Subclasses:
GoldenTCollisionManager

public abstract class CollisionManager
extends java.lang.Object

Collision Manager API This collision manager class is abstract and is intended to be extended by a subclass that specifies the mechanics for a specific game. It has built-in methods to process collisions between objects and between objects and borders


Constructor Summary
CollisionManager()
           
 
Method Summary
protected  void act(Collidable object1, Collidable object2)
          Calls the actOnCollision method for each of the object involved in a collision.
 void collides(Collidable object1, Collidable object2)
          Process collisions between two objects.
 void collides(Collidable object1, java.util.List<Collidable> listOfObjects)
          Process collisions between an object and a list of objects.
 void collides(java.util.List<Collidable> listOfObjects)
          Process collisions in a list objects.
 void collides(java.util.List<Collidable> list1, java.util.List<Collidable> list2)
          Process collision between two lists of objects.
 void processBorders(Collidable object, double worldWidth, double worldHeight)
          Process border collisions for a given object.
 void processBorders(Collidable object, double top, double bottom, double left, double right)
          Process border collisions for a given object.
protected  void processBottomBorder(Collidable object, double bottom)
          Process collision with bottom border.
protected  void processLeftBorder(Collidable object, double left)
          Process collision with left border.
protected  void processRightBorder(Collidable object, double right)
          Process collision with right border.
protected  void processTopBorder(Collidable object, double top)
          Process collision with top border.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollisionManager

public CollisionManager()
Method Detail

act

protected void act(Collidable object1,
                   Collidable object2)
Calls the actOnCollision method for each of the object involved in a collision. It's protected so that the method can be overwritten by subclasses to customize behavior

Parameters:
object1 - an object that implements the interface Collidable
object2 - an object that implements the interface Collidable

collides

public void collides(Collidable object1,
                     Collidable object2)
Process collisions between two objects. If a collision is detected, both objects are called to act according to their behavior defined in their actOnCollision method

Parameters:
object1 - an object that implements the interface Collidable
object2 - an object that implements the interface Collidable

collides

public void collides(Collidable object1,
                     java.util.List<Collidable> listOfObjects)
Process collisions between an object and a list of objects. If a collision is detected between any pair of objects, both objects are called to act according to their behavior defined in their actOnCollision method

Parameters:
object1 - an object that implements the interface Collidable
listOfObjects - a list of Collidable objects

collides

public void collides(java.util.List<Collidable> listOfObjects)
Process collisions in a list objects. If a collision is detected between any pair of objects within the list, both objects are called to act according to their behavior defined in their actOnCollision method

Parameters:
listOfObjects - a list of Collidable objects

collides

public void collides(java.util.List<Collidable> list1,
                     java.util.List<Collidable> list2)
Process collision between two lists of objects. If a collision is detected between any pair of objects, both objects are called to act according to their behavior defined in their actOnCollision method

Parameters:
list1 - a list of Collidable objects
list2 - a list of Collidable objects

processBorders

public void processBorders(Collidable object,
                           double worldWidth,
                           double worldHeight)
Process border collisions for a given object. Bouncing is the default behavior

Parameters:
object - an object that implements the interface Collidable
worldWidth - width of the game world
worldHeight - height of the game world

processBorders

public void processBorders(Collidable object,
                           double top,
                           double bottom,
                           double left,
                           double right)
Process border collisions for a given object. Bouncing is the default behavior

Parameters:
object - an object that implements the interface Collidable
top - location of the top border of the game world
bottom - location of the bottom border of the game world
left - location of the left border of the game world
right - location of the right border of the game world

processTopBorder

protected void processTopBorder(Collidable object,
                                double top)
Process collision with top border. Bouncing is the default behavior. It's protected so it can be overwritten to customize behavior.

Parameters:
object - an object that implements the interface Collidable
top - location of the top border of the game world

processBottomBorder

protected void processBottomBorder(Collidable object,
                                   double bottom)
Process collision with bottom border. Bouncing is the default behavior. It's protected so it can be overwritten to customize behavior.

Parameters:
object - an object that implements the interface Collidable
bottom - location of the bottom border of the game world

processLeftBorder

protected void processLeftBorder(Collidable object,
                                 double left)
Process collision with left border. Bouncing is the default behavior. It's protected so it can be overwritten to customize behavior.

Parameters:
object - an object that implements the interface Collidable
left - location of the left border of the game world

processRightBorder

protected void processRightBorder(Collidable object,
                                  double right)
Process collision with right border. Bouncing is the default behavior. It's protected so it can be overwritten to customize behavior.

Parameters:
object - an object that implements the interface Collidable
right - location of the right border of the game world