The Game Engine  1
CollisionRectangle Class Reference

This defines CollisionRectangle boundaries and data for objects/levels. More...

#include <CollisionObject.h>

+ Inheritance diagram for CollisionRectangle:
+ Collaboration diagram for CollisionRectangle:

Public Member Functions

 CollisionRectangle (string n="")
 
 CollisionRectangle (string n, Point2D pt, double w, double h)
 
double getLeft ()
 Gets the Left edge position. More...
 
double getRight ()
 Gets the Right edge position. More...
 
double getTop ()
 Gets the Top edge position. More...
 
double getBottom ()
 Gets the Bottom edge position. More...
 
virtual pair< WorldObject
*, CollisionObject * > 
collision (const CollisionObject *c, WorldObject *wo, WorldObject *mObj) const
 Check collision with objects implements rectangle on rectangle. More...
 
virtual void draw (const Point2D &pos)
 Draws the collision data to the screen. More...
 
virtual CollisionObjectType getType () const
 This provides a simple interface to determine types of objects. More...
 
- Public Member Functions inherited from CollisionObject
 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...
 

Public Attributes

double width
 Rectangle's width. More...
 
double height
 Rectangle's height. More...
 
- Public Attributes inherited from CollisionObject
Point2D mPos
 The position of the center of the collision data. More...
 

Additional Inherited Members

- Public Types inherited from CollisionObject
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...
 
- Protected Attributes inherited from CollisionObject
string name
 Name of the collision type. More...
 
Uint32 color
 The collision box color. More...
 

Detailed Description

This defines CollisionRectangle boundaries and data for objects/levels.

This class is tasked with the following:

  • Defining a collision rectangle.
    • Checking collisions with other Rectangles
    • Checking collisions with circles

Definition at line 75 of file CollisionObject.h.

Constructor & Destructor Documentation

CollisionRectangle::CollisionRectangle ( string  n = "")
inline

Definition at line 78 of file CollisionObject.h.

CollisionRectangle::CollisionRectangle ( string  n,
Point2D  pt,
double  w,
double  h 
)
inline

Definition at line 79 of file CollisionObject.h.

Member Function Documentation

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

Check collision with objects implements rectangle on rectangle.

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 .

check rect vs rect really just axis aligned box check (simpler)

Implements CollisionObject.

Definition at line 85 of file CollisionObject.cpp.

+ Here is the call graph for this function:

void CollisionRectangle::draw ( const Point2D pos)
virtual

Draws the collision data to the screen.

Implements CollisionObject.

Definition at line 32 of file CollisionObject.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double CollisionRectangle::getBottom ( )

Gets the Bottom edge position.

Definition at line 175 of file CollisionObject.cpp.

+ Here is the caller graph for this function:

double CollisionRectangle::getLeft ( )

Gets the Left edge position.

Definition at line 169 of file CollisionObject.cpp.

+ Here is the caller graph for this function:

double CollisionRectangle::getRight ( )

Gets the Right edge position.

Definition at line 171 of file CollisionObject.cpp.

+ Here is the caller graph for this function:

double CollisionRectangle::getTop ( )

Gets the Top edge position.

Definition at line 173 of file CollisionObject.cpp.

+ Here is the caller graph for this function:

virtual CollisionObjectType CollisionRectangle::getType ( ) const
inlinevirtual

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

Implements CollisionObject.

Definition at line 113 of file CollisionObject.h.

Member Data Documentation

double CollisionRectangle::height

Rectangle's height.

Definition at line 81 of file CollisionObject.h.

double CollisionRectangle::width

Rectangle's width.

Definition at line 80 of file CollisionObject.h.


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