|
The Game Engine
1
|
Base class for Any object that will ever be drawn to the screen. More...
#include <WorldObject.h>
Inheritance diagram for WorldObject:
Collaboration diagram for WorldObject:Public Types | |
| enum | WorldObjectType { SPRITE, BACKGROUND, MENU, TEXT, PARTICLESYSTEM } |
| 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 | |
| WorldObject (std::string name, Point2D pos=Point2D(), int z=0) | |
| virtual void | draw ()=0 |
| Draws the Object. More... | |
| virtual void | drawCollisions () |
| Draws CollisionObject data for the Object. More... | |
| void | drawCollisions (vector< CollisionObject * > &vec, const Point2D &pos) |
| Draws CollisionObject data for the Object. More... | |
| virtual void | update () |
| Update to run each loop. More... | |
| virtual void | runBehavior () |
| Behavior that WorldObject follows. More... | |
| void | setPosition (double x, double y) |
| Sets the WorldObject's x an y coordinate. More... | |
| void | setPosition (Point2D pos) |
| Sets the WorldObject's x an y coordinate. More... | |
| void | setBasePosition (double x, double y) |
| Sets the WorldObject's x an y coordinate relative to base pos. More... | |
| void | setBasePosition (Point2D pos) |
| Sets the WorldObject's x an y coordinate relative to base pos. More... | |
| void | setCenterPosition (double x, double y) |
| Sets the WorldObject's x an y coordinate relative to base pos. More... | |
| void | setCenterPosition (Point2D pos) |
| Sets the WorldObject's x an y coordinate relative to base pos. More... | |
| void | move (double dx=0.0, double dy=0.0) |
| Move by given amount NOTE: This is an instantaneous movement by a given amount and does not correspond to physics which is set to do the updated amount per second. More... | |
| virtual void | move (Point2D direction) |
| Moves the WorldObject relative to the current pos. More... | |
| virtual void | moveTowards (Point2D direction) |
| Move towards a given coordinate (path finding) More... | |
| Point2D | getPosition () |
| Gets the WorldObject's position. More... | |
| void | setTransparency (float f) |
| Sets the WorldObject's transparency. More... | |
| float | getTransparency () |
| Gets the WorldObject's transparency. More... | |
| void | setAngle (float a) |
| Sets the WorldObject's angle in degrees. More... | |
| float | getAngle () |
| Gets the WorldObject's angle. More... | |
| void | setVelocity (Point2D vel) |
| Sets the WorldObject's velocity as a vector (will set MaxVelocity if needed) More... | |
| void | setVelocity (double xVel, double yVel) |
| Sets the WorldObject's velocity from coordinates (will set MaxVelocity if needed) More... | |
| Point2D | getVelocity () |
| Gets the WorldObject's Velocity. More... | |
| void | setMaxVelocity (Point2D vel) |
| Sets the WorldObject's MaxVelocity (magnitude) from (x,y) and transforms into a magnitude. More... | |
| void | setMaxVelocity (double vel, Point2D dir) |
| Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More... | |
| void | setMaxSpeed (double vel) |
| Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More... | |
| Point2D | getMaxVelocity () |
| Gets the WorldObject's Max Velocity. More... | |
| double | getMaxSpeed () |
| Gets the WorldObject's Max Speed. More... | |
| double | getMaxSpeedSquared () |
| Gets the WorldObject's Max Speed Squared (cheaper operation). More... | |
| void | setAcceleration (Point2D accel) |
| Sets the WorldObject's Acceleration in (x,y) coords. More... | |
| Point2D | getAcceleration () |
| Gets the WorldObject's Acceleration. More... | |
| void | setZOrder (int i) |
| int | getZOrder () |
| std::string | getName () |
| returns the WorldObject's name More... | |
| bool | operator< (WorldObject &rhs) |
| Sort worldObjects. More... | |
| virtual Point2D | getBasePos ()=0 |
| Obtain Base Pos for drawing. More... | |
| virtual Point2D | getCenterPos ()=0 |
| Obtain Center Pos for Collisions. More... | |
| virtual WorldObjectType | getType ()=0 |
| This provides a simple interface to determine types of objects. More... | |
Protected Attributes | |
| std::string | mName |
| WorldObject's name. More... | |
| Point2D | mPos |
| The current (x,y) position. More... | |
| Point2D | mVelocity |
| The current velocity vector. More... | |
| Point2D | mMaxVelocity |
| The max velocity is the max possible velocity where lengthis the speed. More... | |
| double | mMaxSpeed |
| The max Speed if MaxVelocity is 0 to store val. More... | |
| Point2D | mAcceleration |
| The current acceleration vector. More... | |
| bool | mVisible |
| Determine if Object should be visible. More... | |
| float | mTransparency |
| Transparency! More... | |
| float | mAngle |
| Angle of rotation. More... | |
| float | mScale |
| Scale for the sprit. More... | |
| int | ZOrder |
| Stacking order. Determines what draws on top. (subsorted by position) More... | |
| long | mLastUpdate |
| Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More... | |
| long | mLastDraw |
| Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More... | |
| bool | mUnused |
| Determines whether or not this object's update function should run. More... | |
| Behavior | mBehavior |
| Behavior to act each loop if !mUnused. More... | |
Base class for Any object that will ever be drawn to the screen.
This class is tasked with the following:
Definition at line 19 of file WorldObject.h.
This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency.
| Enumerator | |
|---|---|
| SPRITE | |
| BACKGROUND | |
| MENU | |
| TEXT | |
| PARTICLESYSTEM | |
Definition at line 28 of file WorldObject.h.
|
pure virtual |
Draws the Object.
Implemented in ParticleSystem, Sprite, Text, Background, and Menu.
|
virtual |
Draws CollisionObject data for the Object.
Reimplemented in ParticleSystem, Background, Sprite, and Menu.
Definition at line 25 of file WorldObject.cpp.
Here is the caller graph for this function:| void WorldObject::drawCollisions | ( | vector< CollisionObject * > & | vec, |
| const Point2D & | pos | ||
| ) |
Draws CollisionObject data for the Object.
Definition at line 48 of file WorldObject.cpp.
|
inline |
Gets the WorldObject's Acceleration.
Definition at line 220 of file WorldObject.h.
|
inline |
Gets the WorldObject's angle.
Definition at line 136 of file WorldObject.h.
|
pure virtual |
Obtain Base Pos for drawing.
Implemented in ParticleSystem, Sprite, Background, Text, and Menu.
Here is the caller graph for this function:
|
pure virtual |
Obtain Center Pos for Collisions.
Implemented in ParticleSystem, Sprite, Background, Text, and Menu.
Here is the caller graph for this function:| double WorldObject::getMaxSpeed | ( | ) |
Gets the WorldObject's Max Speed.
Definition at line 54 of file WorldObject.cpp.
Here is the call graph for this function:| double WorldObject::getMaxSpeedSquared | ( | ) |
Gets the WorldObject's Max Speed Squared (cheaper operation).
if mMaxspeed 0 then use the lengthsquared otherwise use the mMaxSpeed squared
Definition at line 58 of file WorldObject.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Gets the WorldObject's Max Velocity.
Definition at line 199 of file WorldObject.h.
|
inline |
returns the WorldObject's name
Definition at line 228 of file WorldObject.h.
|
inline |
Gets the WorldObject's position.
Definition at line 114 of file WorldObject.h.
Here is the caller graph for this function:
|
inline |
Gets the WorldObject's transparency.
Definition at line 125 of file WorldObject.h.
|
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 ParticleSystem, Sprite, Background, Text, and Menu.
Here is the caller graph for this function:
|
inline |
Gets the WorldObject's Velocity.
Definition at line 165 of file WorldObject.h.
|
inline |
|
inline |
Move by given amount NOTE: This is an instantaneous movement by a given amount and does not correspond to physics which is set to do the updated amount per second.
| dx | Amount to move x relative to current position |
| dy | Amount to move y relative to current position |
Definition at line 97 of file WorldObject.h.
Here is the caller graph for this function:
|
inlinevirtual |
Moves the WorldObject relative to the current pos.
| direction | Direction to move the WorldObject |
Definition at line 103 of file WorldObject.h.
|
virtual |
Move towards a given coordinate (path finding)
| direction | Direction to move the WorldObject towards |
Definition at line 63 of file WorldObject.cpp.
|
inline |
Sort worldObjects.
Definition at line 233 of file WorldObject.h.
Here is the call graph for this function:
|
virtual |
Behavior that WorldObject follows.
Reimplemented in ParticleSystem, and Sprite.
Definition at line 43 of file WorldObject.cpp.
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's Acceleration in (x,y) coords.
| accel | Acceleration in (x,y) coords |
Definition at line 215 of file WorldObject.h.
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's angle in degrees.
| a | Angle in degrees |
Definition at line 131 of file WorldObject.h.
|
inline |
Sets the WorldObject's x an y coordinate relative to base pos.
Definition at line 75 of file WorldObject.h.
Here is the call graph for this function:
|
inline |
Sets the WorldObject's x an y coordinate relative to base pos.
Definition at line 80 of file WorldObject.h.
Here is the call graph for this function:
|
inline |
Sets the WorldObject's x an y coordinate relative to base pos.
Definition at line 85 of file WorldObject.h.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's x an y coordinate relative to base pos.
Definition at line 90 of file WorldObject.h.
Here is the call graph for this function:
|
inline |
Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified.
| vel | MaxVelocity as magnitude |
Definition at line 187 of file WorldObject.h.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's MaxVelocity (magnitude) from (x,y) and transforms into a magnitude.
| vel | MaxVelocity in (x,y) coords |
Definition at line 171 of file WorldObject.h.
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified.
| vel | MaxVelocity as magnitude |
| dir | Direction of velocity |
Definition at line 178 of file WorldObject.h.
Here is the call graph for this function:
|
inline |
Sets the WorldObject's x an y coordinate.
Definition at line 65 of file WorldObject.h.
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's x an y coordinate.
Definition at line 70 of file WorldObject.h.
|
inline |
Sets the WorldObject's transparency.
| f | The WorldObject's transparancy [0,1] other values will be force set |
Definition at line 120 of file WorldObject.h.
|
inline |
Sets the WorldObject's velocity as a vector (will set MaxVelocity if needed)
| vel | Velocity in (x,y) coords |
Definition at line 142 of file WorldObject.h.
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Sets the WorldObject's velocity from coordinates (will set MaxVelocity if needed)
| xVel | Velocity x coord |
| yVel | Velocity y coord |
Definition at line 154 of file WorldObject.h.
Here is the call graph for this function:
|
inline |
Definition at line 222 of file WorldObject.h.
|
virtual |
Update to run each loop.
Reimplemented in ParticleSystem, Sprite, Text, Background, and Menu.
Definition at line 27 of file WorldObject.cpp.
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
The current acceleration vector.
Definition at line 262 of file WorldObject.h.
|
protected |
Angle of rotation.
Definition at line 268 of file WorldObject.h.
|
protected |
Behavior to act each loop if !mUnused.
Definition at line 280 of file WorldObject.h.
|
protected |
Number that indicates when the Object has last updated. Overflows in about 24 days so no worries.
Definition at line 276 of file WorldObject.h.
|
protected |
Number that indicates when the Object has last updated. Overflows in about 24 days so no worries.
Definition at line 274 of file WorldObject.h.
|
protected |
The max Speed if MaxVelocity is 0 to store val.
Definition at line 260 of file WorldObject.h.
|
protected |
The max velocity is the max possible velocity where lengthis the speed.
Definition at line 258 of file WorldObject.h.
|
protected |
WorldObject's name.
Definition at line 252 of file WorldObject.h.
|
protected |
The current (x,y) position.
Definition at line 254 of file WorldObject.h.
|
protected |
Scale for the sprit.
Definition at line 270 of file WorldObject.h.
|
protected |
Transparency!
Definition at line 266 of file WorldObject.h.
|
protected |
Determines whether or not this object's update function should run.
Definition at line 278 of file WorldObject.h.
|
protected |
The current velocity vector.
Definition at line 256 of file WorldObject.h.
|
protected |
Determine if Object should be visible.
Definition at line 264 of file WorldObject.h.
|
protected |
Stacking order. Determines what draws on top. (subsorted by position)
Definition at line 272 of file WorldObject.h.