The Game Engine  1
CollisionObject Class Referenceabstract

This defines CollisionObject boundaries and data for objects/backgrounds. More...

#include <CollisionObject.h>

+ Inheritance diagram for CollisionObject:
+ Collaboration diagram for CollisionObject:

Public Types

enum  CollisionObjectType { COLLISIONRECTANGLE, COLLISIONCIRCLE, COLLISIONSEGMENT }
 This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency. More...
 

Public Member Functions

 CollisionObject (string n)
 
bool checkCollisions (const vector< CollisionObject * > &c, const Point2D cPos, const Point2D pos, vector< string > names=vector< string >())
 Check collision with objects. More...
 
virtual pair< WorldObject
*, CollisionObject * > 
collision (const CollisionObject *c, WorldObject *wo, WorldObject *mObj) const =0
 Check collision with objects. More...
 
virtual void draw (const Point2D &pos)=0
 Draws the collision data to the screen. More...
 
virtual CollisionObjectType getType () const =0
 This provides a simple interface to determine types of objects. More...
 

Public Attributes

Point2D mPos
 The position of the center of the collision data. More...
 

Protected Attributes

string name
 Name of the collision type. More...
 
Uint32 color
 The collision box color. More...
 

Detailed Description

This defines CollisionObject boundaries and data for objects/backgrounds.

This class is tasked with the following:

  • being a parent for collision bound types.

Definition at line 20 of file CollisionObject.h.

Member Enumeration Documentation

This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency.

Todo:
make sure to put all CollisionObject children in here!
Enumerator
COLLISIONRECTANGLE 
COLLISIONCIRCLE 
COLLISIONSEGMENT 

Definition at line 30 of file CollisionObject.h.

Constructor & Destructor Documentation

CollisionObject::CollisionObject ( string  n)
inline

Definition at line 23 of file CollisionObject.h.

Member Function Documentation

bool CollisionObject::checkCollisions ( const vector< CollisionObject * > &  c,
const Point2D  cPos,
const Point2D  pos,
vector< string >  names = vector<string>() 
)

Check collision with objects.

Parameters
cthe collision data associated with the sprite to check collision with.
cPosthe position of the sprite we want to check collision with.
posthe current sprite's position.
namesthe names that should be checked (empty checks all)
Returns
Returns true if any of the object's collision datas are colliding .

Definition at line 74 of file CollisionObject.cpp.

virtual pair<WorldObject*, CollisionObject*> CollisionObject::collision ( const CollisionObject c,
WorldObject wo,
WorldObject mObj 
) const
pure virtual

Check collision with objects.

Parameters
ca single collision data for an object
woPointer to Object with checking bound
mObjthe current collision's world object
Returns
Returns true if any of the object's collision datas are colliding .

Implemented in CollisionSegment, CollisionCircle, and CollisionRectangle.

+ Here is the caller graph for this function:

virtual void CollisionObject::draw ( const Point2D pos)
pure virtual

Draws the collision data to the screen.

Implemented in CollisionSegment, CollisionCircle, and CollisionRectangle.

virtual CollisionObjectType CollisionObject::getType ( ) const
pure virtual

This provides a simple interface to determine types of objects.

Returns the name of the Class and Descendants i.e. Something inheriting from Sprite would look like Sprite:Thing

Implemented in CollisionSegment, CollisionCircle, and CollisionRectangle.

+ Here is the caller graph for this function:

Member Data Documentation

Uint32 CollisionObject::color
protected

The collision box color.

Definition at line 63 of file CollisionObject.h.

Point2D CollisionObject::mPos

The position of the center of the collision data.

Definition at line 23 of file CollisionObject.h.

string CollisionObject::name
protected

Name of the collision type.

Todo:
make this actually be useful

Definition at line 62 of file CollisionObject.h.


The documentation for this class was generated from the following files: