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

Bear Class Reference

#include <bear.h>

Inheritance diagram for Bear:

GameObject List of all members.

Public Types

enum  direction {
  EAST = 0, SOUTHEAST, SOUTH, SOUTHWEST,
  WEST, NORTHWEST, NORTH, NORTHEAST
}

Public Methods

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

void SetupDirection ()
bool isWalking ()
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 Methods

void setWalk (double, double)

Private Attributes

direction movingDir
bool walking
int notmoving_delay
int velocity_delay
nnctime lastwalk
Velocity walk_velocity
double acceleration
double xMinVel
double xMaxVel
double yMinVel
double yMaxVel

Member Enumeration Documentation

enum Bear::direction
 

Enumeration values:
EAST 
SOUTHEAST 
SOUTH 
SOUTHWEST 
WEST 
NORTHWEST 
NORTH 
NORTHEAST 

Definition at line 16 of file bear.h.


Constructor & Destructor Documentation

Bear::Bear ObjectManager  
 

Definition at line 11 of file bear.cpp.

References acceleration, BEAR_IMG_FILE, Velocity::dx, Velocity::dy, EAST, Sprite::EnableAnimation(), lastwalk, movingDir, nnctime::msecs, Velocity::pertime, Sprite::ReverseAnimation(), nnctime::secs, Sprite::SetAnimateTime(), Sprite::SetAnimationEndFrame(), Sprite::SetAnimationStartFrame(), GameObject::SetCollidable(), GameObject::SetDamagable(), GameObject::SetDamage(), Sprite::SetFrame(), GameObject::sprite, Util_GetTime(), Util_parseImage(), walk_velocity, walking, xMaxVel, xMinVel, yMaxVel, and yMinVel.

Bear::~Bear  
 

Definition at line 50 of file bear.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 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(), setWalk(), ObjectManager::think(), MainChar::think(), Crosshair::think(), and 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().

bool Bear::isWalking  
 

Definition at line 240 of file bear.cpp.

References walking.

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(), and UFO::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(), MainChar::MainChar(), and UFO::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(), MainChar::MainChar(), and UFO::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(), UFO::SetupPosition(), UFO::think(), MainChar::think(), BearSpawnPoint::think(), and think().

void Bear::SetupDirection  
 

void Bear::setWalk double   ,
double   
[private]
 

Definition at line 93 of file bear.cpp.

References EAST, Sprite::EnableAnimation(), Sprite::GetHeight(), Sprite::GetWidth(), Sprite::GetX(), Sprite::GetY(), GameObject::GetY(), movingDir, NORTH, NORTHEAST, NORTHWEST, NNCMath::PI, Sprite::ReverseAnimation(), Sprite::SetAnimateTime(), Sprite::SetAnimationEndFrame(), Sprite::SetAnimationStartFrame(), Sprite::SetFrame(), SOUTH, SOUTHEAST, SOUTHWEST, GameObject::sprite, and WEST.

Referenced by think().

void Bear::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 54 of file bear.cpp.

References acceleration, Velocity::dx, Velocity::dy, ObjectManager::GetMainChar(), ObjectManager::GetSubWorld(), GameObject::GetX(), GameObject::GetY(), lastwalk, nnctime::msecs, GameObject::OM, Velocity::pertime, GameObject::SetPosition(), setWalk(), SubWorld::SubWorldToScreen(), Util_TimePassed(), walk_velocity, xMaxVel, xMinVel, GameObject::Xpos, yMaxVel, yMinVel, and GameObject::Ypos.


Member Data Documentation

double Bear::acceleration [private]
 

Definition at line 35 of file bear.h.

Referenced by Bear(), and think().

nnctime Bear::lastwalk [private]
 

Definition at line 31 of file bear.h.

Referenced by Bear(), and think().

direction Bear::movingDir [private]
 

Definition at line 23 of file bear.h.

Referenced by Bear(), and setWalk().

int Bear::notmoving_delay [private]
 

Definition at line 29 of file bear.h.

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 think().

Sprite* GameObject::sprite [protected, inherited]
 

Access this only when necessary.

Definition at line 214 of file object.h.

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

int Bear::velocity_delay [private]
 

Definition at line 30 of file bear.h.

Velocity Bear::walk_velocity [private]
 

Definition at line 34 of file bear.h.

Referenced by Bear(), and think().

bool Bear::walking [private]
 

Definition at line 25 of file bear.h.

Referenced by Bear(), and isWalking().

double Bear::xMaxVel [private]
 

Definition at line 36 of file bear.h.

Referenced by Bear(), and think().

double Bear::xMinVel [private]
 

Definition at line 36 of file bear.h.

Referenced by Bear(), 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 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 Bear::yMaxVel [private]
 

Definition at line 36 of file bear.h.

Referenced by Bear(), and think().

double Bear::yMinVel [private]
 

Definition at line 36 of file bear.h.

Referenced by Bear(), 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 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:21 2002 for nnc by doxygen1.3-rc1