Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

UFO Class Reference

#include <ufo.h>

Inheritance diagram for UFO:

GameObject List of all members.

Public Types

enum  direction {
  GOING_UP, GOING_DOWN, GOING_RIGHT, GOING_LEFT,
  MAX_DIR, NOT_MOVING
}
enum  position {
  UPPER_LEFT, UPPER_RIGHT, LOWER_LEFT, LOWER_RIGHT,
  MAX_POS, INBETWEEN
}

Public Methods

 UFO (ObjectManager &)
 ~UFO ()
void think ()
 Overload this function to give your object a way to do things.

void SetupPosition ()
void SetupDirection ()
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 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.

SpritegetSprite () 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

Spritesprite
 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.

ObjectManagerOM
 Reference to the ObjMgr.


Private Attributes

direction movingDir
position currentPos
double x
double y
double sinex
double siney
double radius
radian rpos
int notmoving_delay
int velocity_delay
int circ_delay
double velocity
nnctime lasttime
nnctime lastcirctime
int velocity_count

Member Enumeration Documentation

enum UFO::direction
 

Enumeration values:
GOING_UP 
GOING_DOWN 
GOING_RIGHT 
GOING_LEFT 
MAX_DIR 
NOT_MOVING 

Definition at line 17 of file ufo.h.

enum UFO::position
 

Enumeration values:
UPPER_LEFT 
UPPER_RIGHT 
LOWER_LEFT 
LOWER_RIGHT 
MAX_POS 
INBETWEEN 

Definition at line 18 of file ufo.h.


Constructor & Destructor Documentation

UFO::UFO ObjectManager  
 

Definition at line 14 of file ufo.cpp.

References circ_delay, currentPos, lastcirctime, lasttime, MAX_POS, movingDir, NOT_MOVING, notmoving_delay, radius, rpos, GameObject::SetCollidable(), GameObject::SetDamagable(), GameObject::SetDamage(), SetupDirection(), SetupPosition(), sinex, siney, GameObject::sprite, UFO_IMG_FILE, Util_GetTime(), Util_parseImage(), Util_Random(), _radian::value, velocity, velocity_count, and velocity_delay.

UFO::~UFO  
 

Definition at line 51 of file ufo.cpp.


Member Function Documentation

virtual void GameObject::animate   [inline, virtual, inherited]
 

Calls the animate sprite function.

Calls the animation function of a sprite if the object has a sprite.

See also:
think(), draw(Graphics &GD)

Definition at line 56 of file object.h.

void GameObject::Damage double    howmuch = 1 [inherited]
 

Damages the object.

Damages the object with a default power of 1

  • If damage goes to 0, SetDead(true) is called.

Parameters:
howmuch the strength of the damage taken
See also:
SetDamage(double howhigh)

Definition at line 98 of file object.cpp.

References GameObject::damage, GameObject::IsDamagable(), and GameObject::SetDead().

Referenced by ExplodeObject::think().

virtual Rect GameObject::draw Surface   s [inline, virtual, inherited]
 

Draws onto a given Surface.

Draws the sprite of the current object if it has one.

Parameters:
s A surface to draw to
See also:
draw(Graphics &GD)
Returns:
A rectangle describing the area drawn to or R(-9999,-9999,0,0) if not drawn.

Definition at line 49 of file object.h.

virtual Rect GameObject::draw Graphics   GD [inline, virtual, inherited]
 

draws onto a given Graphics Device

Draws the sprite of the current object if it has one.

Parameters:
GD the graphics device to draw to
See also:
draw(Surface *s)
Returns:
A rectangle describing the area drawn to or R(-9999,-9999,0,0) if not drawn.

Definition at line 40 of file object.h.

Rect GameObject::GetBoundingRect   [inherited]
 

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.

Returns:
a rectangle describing the shape of the bounding box.

Definition at line 51 of file object.cpp.

References Sprite::GetHeight(), ObjectManager::GetSubWorld(), Sprite::GetWidth(), Sprite::GetX(), Sprite::GetY(), GameObject::OM, Rect, SubWorld::ScreenToSubWorld(), GameObject::sprite, and Util_BuildRect().

int GameObject::GetLayer   const [inherited]
 

Returns the layer of the object.

Returns:
the value of the layer the object is in
See also:
ObjectManager, SetLayer(int)

Definition at line 88 of file object.cpp.

References GameObject::layer.

Referenced by ObjectManager::AddToAnyObjectList(), and ObjectManager::think().

string GameObject::getName   const [inline, inherited]
 

Returns a string that defines the name of this object.

  • this name might be different from the sprite->name
    Returns:
    a string containing the name of the Object.

Definition at line 104 of file object.h.

Sprite* GameObject::getSprite   const [inline, inherited]
 

Returns a pointer to the sprite object.

  • dangerous is the object doesn't have a sprite
    See also:
    getName()
    Returns:
    a pointer to the object's sprite private member.

Definition at line 96 of file object.h.

Referenced by MainChar::FireWeapon().

double GameObject::GetX   const [inherited]
 

Returns the actual X position as a double.

Returns:
the actual floating point X value

Definition at line 68 of file object.cpp.

References GameObject::Xpos.

Referenced by MainChar::FireWeapon(), Game::GameLoop(), Crosshair::Recenter(), MainChar::think(), Crosshair::think(), and Bear::think().

int GameObject::GetXint   const [inherited]
 

Returns the X position rounded to an integer.

Returns:
the X value as a rounded integer

Definition at line 78 of file object.cpp.

References GameObject::Xposi.

Referenced by Game::GameLoop(), MainChar::think(), and ExplodeObject::think().

double GameObject::GetY   const [inherited]
 

Returns the actual Y position as a double.

Returns:
the actual floating point Y value

Definition at line 73 of file object.cpp.

References GameObject::Ypos.

Referenced by ObjectManager::AddToAnyObjectList(), MainChar::FireWeapon(), Game::GameLoop(), Crosshair::Recenter(), Bear::setWalk(), ObjectManager::think(), MainChar::think(), Crosshair::think(), and Bear::think().

int GameObject::GetYint   const [inherited]
 

Returns the Y position rounded to an integer.

Returns:
the Y value as a rounded integer

Definition at line 83 of file object.cpp.

References GameObject::Yposi.

Referenced by Game::GameLoop(), MainChar::think(), and ExplodeObject::think().

bool GameObject::IsCollidable   [inline, inherited]
 

Returns the status of collision.

Returns:
true if this object can be collided into (i.e. can't walk through it)

Definition at line 135 of file object.h.

bool GameObject::IsDamagable   const [inline, inherited]
 

Returns the damagable status of this object.

Returns:
true if this object can be damaged and/or killed

Definition at line 148 of file object.h.

Referenced by GameObject::Damage(), and ExplodeObject::think().

bool GameObject::IsDead   const [inline, inherited]
 

Returns the status of dead.

Returns:
true if object is dead; false otherwise.

Definition at line 119 of file object.h.

Referenced by ExplodeObject::think().

int GameObject::Recenter   [virtual, inherited]
 

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(), GameObject::OM, Sprite::SetPosition(), GameObject::sprite, and GameObject::Ypos.

Referenced by Crosshair::Recenter(), and GameObject::SetPosition().

void GameObject::SetCollidable bool    b [inline, inherited]
 

Sets the collision status of this object.

Parameters:
b set to true if this object is impassible.
See also:
IsCollidable()

Definition at line 142 of file object.h.

Referenced by Bear::Bear(), and UFO().

void GameObject::SetDamagable bool    b [inline, inherited]
 

Sets the damagable status of this object.

Parameters:
b set to true if this object can be damaged and/or killed

Definition at line 154 of file object.h.

Referenced by Bear::Bear(), MainChar::MainChar(), and UFO().

void GameObject::SetDamage double    howhigh = 1 [inherited]
 

Sets how much damage an object can take.

Determines the amount of damage an object can take before SetDead(true) is called.

See also:
Damage(double howmuch)

Definition at line 110 of file object.cpp.

References GameObject::damage.

Referenced by Bear::Bear(), MainChar::MainChar(), and UFO().

void GameObject::SetDead bool    b [inline, inherited]
 

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.

Parameters:
b sets the status of dead
See also:
IsDead()

Definition at line 113 of file object.h.

Referenced by GameObject::Damage(), and ExplodeObject::think().

void GameObject::SetLayer int    l [inherited]
 

Sets the layer of the object.

Parameters:
l the value of the layer
See also:
GetLayer(), ObjectManager

Definition at line 93 of file object.cpp.

References GameObject::layer.

Referenced by Crosshair::Crosshair().

int GameObject::SetPosition double    x,
double    y
[virtual, inherited]
 

Sets the position of the sprite in Subworld-Space.

  • positions are rounded to nearest integer
    • if x or y is "off screen" then the object is either clipped or not-visible (only when Object HasA sprite)
    • x,y are relations to the CENTER of the object.
    • x,y are also in subworld-coordinates
      Parameters:
      x the X parameter of the position in SubWorld space
      y the Y parameter of the position in SubWorld space
      See also:
      Recenter()
      Returns:
      the value returned from Sprite::SetPosition() or 0.

Reimplemented in Crosshair.

Definition at line 24 of file object.cpp.

References GameObject::Recenter(), GameObject::Xpos, GameObject::Xposi, GameObject::Ypos, and GameObject::Yposi.

Referenced by BearSpawnPoint::BearSpawnPoint(), ExplodeObject::ExplodeObject(), MainChar::FireWeapon(), Game::Game(), Crosshair::SetPosition(), SetupPosition(), think(), MainChar::think(), BearSpawnPoint::think(), and Bear::think().

void UFO::SetupDirection  
 

Definition at line 66 of file ufo.cpp.

References currentPos, GOING_LEFT, GOING_RIGHT, GOING_UP, LOWER_LEFT, LOWER_RIGHT, movingDir, NOT_MOVING, Sprite::SetFrame(), GameObject::sprite, UPPER_LEFT, and UPPER_RIGHT.

Referenced by think(), and UFO().

void UFO::SetupPosition  
 

Definition at line 55 of file ufo.cpp.

References currentPos, MAX_POS, GameObject::SetPosition(), sinex, siney, x, and y.

Referenced by think(), and UFO().

void UFO::think   [virtual]
 

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.

See also:
animate()

Reimplemented from GameObject.

Definition at line 106 of file ufo.cpp.

References circ_delay, NNCMath::Cos(), currentPos, GOING_DOWN, GOING_LEFT, GOING_RIGHT, GOING_UP, lastcirctime, lasttime, LOWER_LEFT, LOWER_RIGHT, MAX_DIR, movingDir, NOT_MOVING, notmoving_delay, radius, rpos, GameObject::SetPosition(), SetupDirection(), SetupPosition(), NNCMath::Sin(), sinex, siney, UPPER_LEFT, UPPER_RIGHT, Util_GetTime(), Util_Random(), Util_TimePassed(), _radian::value, velocity, velocity_count, velocity_delay, x, and y.


Member Data Documentation

int UFO::circ_delay [private]
 

Definition at line 31 of file ufo.h.

Referenced by think(), and UFO().

position UFO::currentPos [private]
 

Definition at line 23 of file ufo.h.

Referenced by SetupDirection(), SetupPosition(), think(), and UFO().

nnctime UFO::lastcirctime [private]
 

Definition at line 33 of file ufo.h.

Referenced by think(), and UFO().

nnctime UFO::lasttime [private]
 

Definition at line 33 of file ufo.h.

Referenced by think(), and UFO().

direction UFO::movingDir [private]
 

Definition at line 22 of file ufo.h.

Referenced by SetupDirection(), think(), and UFO().

int UFO::notmoving_delay [private]
 

Definition at line 29 of file ufo.h.

Referenced by think(), and UFO().

ObjectManager& GameObject::OM [protected, inherited]
 

Reference to the ObjMgr.

Definition at line 223 of file object.h.

Referenced by MainChar::FireWeapon(), GameObject::GetBoundingRect(), GameObject::Recenter(), MainChar::Recenter(), MainChar::think(), ExplodeObject::think(), BearSpawnPoint::think(), and Bear::think().

double UFO::radius [private]
 

Definition at line 26 of file ufo.h.

Referenced by think(), and UFO().

radian UFO::rpos [private]
 

Definition at line 27 of file ufo.h.

Referenced by think(), and UFO().

double UFO::sinex [private]
 

Definition at line 25 of file ufo.h.

Referenced by SetupPosition(), think(), and UFO().

double UFO::siney [private]
 

Definition at line 25 of file ufo.h.

Referenced by SetupPosition(), think(), and UFO().

Sprite* GameObject::sprite [protected, inherited]
 

Access this only when necessary.

Definition at line 214 of file object.h.

Referenced by Bear::Bear(), MainChar::ChangeDirection(), Crosshair::Crosshair(), ExplodeObject::ExplodeObject(), GameObject::GameObject(), GameObject::GetBoundingRect(), MainChar::MainChar(), GameObject::Recenter(), MainChar::Recenter(), Crosshair::Recenter(), MainChar::setLook(), Crosshair::SetPosition(), SetupDirection(), Bear::setWalk(), MainChar::setWalking(), Crosshair::think(), UFO(), and GameObject::~GameObject().

double UFO::velocity [private]
 

Definition at line 32 of file ufo.h.

Referenced by think(), and UFO().

int UFO::velocity_count [private]
 

Definition at line 34 of file ufo.h.

Referenced by think(), and UFO().

int UFO::velocity_delay [private]
 

Definition at line 30 of file ufo.h.

Referenced by think(), and UFO().

double UFO::x [private]
 

Definition at line 25 of file ufo.h.

Referenced by SetupPosition(), and think().

double GameObject::Xpos [protected, inherited]
 

X/Y positions for object.

Definition at line 217 of file object.h.

Referenced by GameObject::GameObject(), GameObject::GetX(), GameObject::SetPosition(), Crosshair::SetPosition(), BearSpawnPoint::think(), and Bear::think().

int GameObject::Xposi [protected, inherited]
 

X/Y positions as rounded integers.

Definition at line 220 of file object.h.

Referenced by GameObject::GetXint(), and GameObject::SetPosition().

double UFO::y [private]
 

Definition at line 25 of file ufo.h.

Referenced by SetupPosition(), and think().

double GameObject::Ypos [protected, inherited]
 

X/Y positions for object.

Definition at line 217 of file object.h.

Referenced by GameObject::GameObject(), GameObject::GetY(), GameObject::Recenter(), GameObject::SetPosition(), Crosshair::SetPosition(), BearSpawnPoint::think(), and Bear::think().

int GameObject::Yposi [protected, inherited]
 

X/Y positions as rounded integers.

Definition at line 220 of file object.h.

Referenced by GameObject::GetYint(), and GameObject::SetPosition().


The documentation for this class was generated from the following files:
Generated on Sun Dec 8 12:02:22 2002 for nnc by doxygen1.3-rc1