#include <object.h>
Inheritance diagram for GameObject:
Public Methods | |
GameObject (ObjectManager &, string name="") | |
Constructor. | |
~GameObject () | |
Destructor. | |
virtual Rect | draw (Graphics &GD) |
draws onto a given Graphics Device | |
virtual Rect | draw (Surface *s) |
Draws onto a given Surface. | |
virtual void | animate () |
Calls the animate sprite function. | |
virtual void | think () |
Overload this function to give your object a way to do things. | |
virtual int | SetPosition (double x, double y) |
Sets the position of the sprite in Subworld-Space. | |
virtual int | Recenter () |
Recenter the object based on the subworld. | |
Sprite * | getSprite () const |
Returns a pointer to the sprite object. | |
string | getName () const |
Returns a string that defines the name of this object. | |
void | SetDead (bool b) |
If this field is true, the object manager will remove this object from its list. | |
bool | IsDead () const |
Returns the status of dead. | |
Rect | GetBoundingRect () |
Get the bounding rectangle of the object. | |
bool | IsCollidable () |
Returns the status of collision. | |
void | SetCollidable (bool b) |
Sets the collision status of this object. | |
bool | IsDamagable () const |
Returns the damagable status of this object. | |
void | SetDamagable (bool b) |
Sets the damagable status of this object. | |
int | GetXint () const |
Returns the X position rounded to an integer. | |
int | GetYint () const |
Returns the Y position rounded to an integer. | |
double | GetX () const |
Returns the actual X position as a double. | |
double | GetY () const |
Returns the actual Y position as a double. | |
int | GetLayer () const |
Returns the layer of the object. | |
void | SetLayer (int l) |
Sets the layer of the object. | |
void | Damage (double howmuch=1) |
Damages the object. | |
void | SetDamage (double howhigh=1) |
Sets how much damage an object can take. | |
Protected Attributes | |
Sprite * | sprite |
Access this only when necessary. | |
double | Xpos |
X/Y positions for object. | |
double | Ypos |
X/Y positions for object. | |
int | Xposi |
X/Y positions as rounded integers. | |
int | Yposi |
X/Y positions as rounded integers. | |
ObjectManager & | OM |
Reference to the ObjMgr. | |
Private Attributes | |
string | name |
bool | dead |
bool | collide |
bool | damagable |
int | layer |
double | damage |
|
Constructor. Constructor takes a reference to the ObjectManager and a name for this object.
Definition at line 5 of file object.cpp. References collide, damagable, dead, layer, name, sprite, Xpos, and Ypos. |
|
Destructor. The destructor of GameObject
Definition at line 16 of file object.cpp. References sprite. |
|
Calls the animate sprite function. Calls the animation function of a sprite if the object has a sprite.
|
|
Damages the object. Damages the object with a default power of 1
Definition at line 98 of file object.cpp. References damage, IsDamagable(), and SetDead(). Referenced by ExplodeObject::think(). |
|
Draws onto a given Surface. Draws the sprite of the current object if it has one.
|
|
draws onto a given Graphics Device Draws the sprite of the current object if it has one.
|
|
Get the bounding rectangle of the object. If the object has a sprite, this returns bounding box that describes the current frame of the sprite. Otherwise, returns Rect(0,0,0,0). NOTE: the rect that is returned is in SubWorld space.
Definition at line 51 of file object.cpp. References Sprite::GetHeight(), ObjectManager::GetSubWorld(), Sprite::GetWidth(), Sprite::GetX(), Sprite::GetY(), OM, Rect, SubWorld::ScreenToSubWorld(), sprite, and Util_BuildRect(). |
|
Returns the layer of the object.
Definition at line 88 of file object.cpp. References layer. Referenced by ObjectManager::AddToAnyObjectList(), and ObjectManager::think(). |
|
Returns a string that defines the name of this object.
|
|
Returns a pointer to the sprite object.
Definition at line 96 of file object.h. Referenced by MainChar::FireWeapon(). |
|
Returns the actual X position as a double.
Definition at line 68 of file object.cpp. References Xpos. Referenced by MainChar::FireWeapon(), Game::GameLoop(), Crosshair::Recenter(), MainChar::think(), Crosshair::think(), and Bear::think(). |
|
Returns the X position rounded to an integer.
Definition at line 78 of file object.cpp. References Xposi. Referenced by Game::GameLoop(), MainChar::think(), and ExplodeObject::think(). |
|
Returns the actual Y position as a double.
Definition at line 73 of file object.cpp. References Ypos. Referenced by ObjectManager::AddToAnyObjectList(), MainChar::FireWeapon(), Game::GameLoop(), Crosshair::Recenter(), Bear::setWalk(), ObjectManager::think(), MainChar::think(), Crosshair::think(), and Bear::think(). |
|
Returns the Y position rounded to an integer.
Definition at line 83 of file object.cpp. References Yposi. Referenced by Game::GameLoop(), MainChar::think(), and ExplodeObject::think(). |
|
Returns the status of collision.
|
|
Returns the damagable status of this object.
Definition at line 148 of file object.h. Referenced by Damage(), and ExplodeObject::think(). |
|
Returns the status of dead.
Definition at line 119 of file object.h. Referenced by ExplodeObject::think(). |
|
Recenter the object based on the subworld. Will relocate the Sprite (if our object has one) to the correct location based on the SubWorld's background location. Reimplemented in Crosshair, and MainChar. Definition at line 36 of file object.cpp. References SubWorld::GetBackground(), Sprite::GetHeight(), ObjectManager::GetSubWorld(), Background::GetY(), OM, Sprite::SetPosition(), sprite, and Ypos. Referenced by Crosshair::Recenter(), and SetPosition(). |
|
Sets the collision status of this object.
Definition at line 142 of file object.h. Referenced by Bear::Bear(), and UFO::UFO(). |
|
Sets the damagable status of this object.
Definition at line 154 of file object.h. Referenced by Bear::Bear(), MainChar::MainChar(), and UFO::UFO(). |
|
Sets how much damage an object can take. Determines the amount of damage an object can take before SetDead(true) is called.
Definition at line 110 of file object.cpp. References damage. Referenced by Bear::Bear(), MainChar::MainChar(), and UFO::UFO(). |
|
If this field is true, the object manager will remove this object from its list. If the object is dead, the ObjectManager should remove this object from memory.
Definition at line 113 of file object.h. Referenced by Damage(), and ExplodeObject::think(). |
|
Sets the layer of the object.
Definition at line 93 of file object.cpp. References layer. Referenced by Crosshair::Crosshair(). |
|
Sets the position of the sprite in Subworld-Space.
Reimplemented in Crosshair. Definition at line 24 of file object.cpp. References Recenter(), Xpos, Xposi, Ypos, and Yposi. Referenced by BearSpawnPoint::BearSpawnPoint(), ExplodeObject::ExplodeObject(), MainChar::FireWeapon(), Game::Game(), Crosshair::SetPosition(), UFO::SetupPosition(), UFO::think(), MainChar::think(), BearSpawnPoint::think(), and Bear::think(). |
|
Overload this function to give your object a way to do things. The "brain" of an object. This function is called repeatedly between frames and you should overload this to describe how your object reacts to events in the game.
Reimplemented in Bear, BearSpawnPoint, Crosshair, ExplodeObject, MainChar, and UFO. Definition at line 65 of file object.h. Referenced by ObjectManager::think(). |
|
Definition at line 229 of file object.h. Referenced by GameObject(). |
|
Definition at line 229 of file object.h. Referenced by GameObject(). |
|
Definition at line 231 of file object.h. Referenced by Damage(), and SetDamage(). |
|
Definition at line 229 of file object.h. Referenced by GameObject(). |
|
Definition at line 230 of file object.h. Referenced by GameObject(), GetLayer(), and SetLayer(). |
|
Definition at line 228 of file object.h. Referenced by GameObject(). |
|
Reference to the ObjMgr.
Definition at line 223 of file object.h. Referenced by MainChar::FireWeapon(), GetBoundingRect(), Recenter(), MainChar::Recenter(), MainChar::think(), ExplodeObject::think(), BearSpawnPoint::think(), and Bear::think(). |
|
Access this only when necessary.
Definition at line 214 of file object.h. Referenced by Bear::Bear(), MainChar::ChangeDirection(), Crosshair::Crosshair(), ExplodeObject::ExplodeObject(), GameObject(), GetBoundingRect(), MainChar::MainChar(), Recenter(), MainChar::Recenter(), Crosshair::Recenter(), MainChar::setLook(), Crosshair::SetPosition(), UFO::SetupDirection(), Bear::setWalk(), MainChar::setWalking(), Crosshair::think(), UFO::UFO(), and ~GameObject(). |
|
X/Y positions for object.
Definition at line 217 of file object.h. Referenced by GameObject(), GetX(), SetPosition(), Crosshair::SetPosition(), BearSpawnPoint::think(), and Bear::think(). |
|
X/Y positions as rounded integers.
Definition at line 220 of file object.h. Referenced by GetXint(), and SetPosition(). |
|
X/Y positions for object.
Definition at line 217 of file object.h. Referenced by GameObject(), GetY(), Recenter(), SetPosition(), Crosshair::SetPosition(), BearSpawnPoint::think(), and Bear::think(). |
|
X/Y positions as rounded integers.
Definition at line 220 of file object.h. Referenced by GetYint(), and SetPosition(). |