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

Object Class Reference

Base class of all objects on the map. More...

#include <objects_common.h>

Inheritance diagram for Object:

Inheritance graph
[legend]
Collaboration diagram for Object:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Object (Sint16 xpos=0, Sint16 ypos=0, const ParameterMap &param=ParameterMap())
bool setPos (Sint16 xcord, Sint16 ycord)
SDL_Rect getCenter () const
 Returns the center of an object.
bool isIn (const SDL_Rect &rect, bool touch=false) const
SDL_Rect * getPos ()
SDL_Rect getDrawPos () const
const Frame getFrame () const
string getName ()
EmptyAnimationPtr loadAnimation (string anim_name, double scale_factor=1, BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, double afps=0, AllignType aallign_type=AT_MD)
 Load an animation bound onto this object from an animation data file.
EmptyAnimationPtr loadAnimation (const Image &abase_image, Uint16 aframes=1, BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, double afps=0, Uint16 astart_pos=0, AllignType aallign_type=AT_MD)
 Load an animation bound onto this object.
EmptyAnimationPtr loadAnimation (const ParameterMap &param=ParameterMap())
 Load an animation based on a parameter map.
bool operator< (const Object &obj) const
Uint16 getType () const
void setType (Uint16 newtype)
void unsetType (Uint16 oldtype)
void switchType (Uint16 newtype)
bool updateAnim (Uint16 dt)
bool setAnim (EmptyAnimationPtr anim, bool start=false)
virtual void resetAnimState ()
 Sets the animation back to the default one.
bool isRunning () const
void mark_delete ()
 Mark an object for deletion.
bool isDeleted ()
virtual void destroy ()
void clearEvents ()
virtual void setEvent (Event *ev)
Uint16 updateEvents (Uint16 dt)
void cancelEvent ()
 Cancel the current event.
void stopEvent ()
 End the current event.
bool getState (Uint32 cstate) const
void setState (Uint32 cstate)
void switchState (Uint32 cstate)
void unsetState (Uint32 cstate)
virtual bool act (Object *)
virtual void touch (Object *)
virtual void enter (Object *)
virtual void untouch (Object *)
virtual void leave (Object *)
virtual void idle (Uint16)

Public Attributes

Uint32 onum

Static Public Attributes

ParameterMap default_parameters

Protected Attributes

ParameterMap parameters
Uint32 state
Eventevent
SDL_Rect pos
Uint16 otype
string name
bool delete_flag
EmptyAnimationPtr anim_orig
EmptyAnimationPtr animation

Detailed Description

Base class of all objects on the map.

An object has a graphical representation (animation), a position, an object type, a type and can be entered/left/touched/untouched/activated.


Member Function Documentation

bool Object::setPos Sint16  xcord,
Sint16  ycord
 

Sets the new position. If the coordinates are not in the map area they are corrected to fit into it.

Returns:
True if no correction was needed

SDL_Rect Object::getCenter  )  const [inline]
 

Returns the center of an object.

Returns:
Center position of the object with width=height=0

bool Object::isIn const SDL_Rect &  rect,
bool  touch = false
const
 

Checks whether this object is partially inside a certain map area.

Parameters:
rect Map area
touch If true an overlapping region is enough, if false the object center has to be inside the specified area.
Returns:
True if the object is inside

bool Object::updateAnim Uint16  dt  ) 
 

Updates the current animation

Returns:
True if the animation is still running

bool Object::setAnim EmptyAnimationPtr  anim,
bool  start = false
 

Specifies the animation to be run (usually a one time animation) and starts it right away. Should not be used with updateAnimState, set ESTATE_ANIM to deactivate an updateAnimState. This is usually controlled by an AnimationEvent

void Object::clearEvents  ) 
 

Clears the event field (sets it to NULL). This should only be used by the event destructor.

Todo:
Is there a way to solve this better?

virtual void Object::setEvent Event ev  )  [virtual]
 

Schedules a new event and cancels any currently running event

Parameters:
ev New event

Reimplemented in Player.

Uint16 Object::updateEvents Uint16  dt  ) 
 

Updates the event (run by the PhysicHandler) and react on the new event state (start, end or cancel an event).

Returns:
New event state

virtual bool Object::act Object  )  [inline, virtual]
 

Try to activate any objects in the current position

Returns:
True if an object could be activated

Reimplemented in Bomb, Door, Exit, Heart, Key, Teleporter, Trigger, and Item.

virtual void Object::touch Object  )  [inline, virtual]
 

Touch an object, called when the object position overlaps with the position of another object for the first time.

Reimplemented in Plant, and Spike.

virtual void Object::enter Object  )  [inline, virtual]
 

Enter an object, called when the object center enters another object position for the first time.

Reimplemented in Water, and Wind.

virtual void Object::untouch Object  )  [inline, virtual]
 

Untouch a touched object, called when the object no longer overlaps with another object.

virtual void Object::leave Object  )  [inline, virtual]
 

Leave an object, called when the object center no longer is inside another object.

Reimplemented in Water, and Wind.

virtual void Object::idle Uint16   )  [inline, virtual]
 

What should the object do all the time? This is run first of all.

Remarks:
This should be called downwards by all derived classes

Reimplemented in Character, Monster, Erik, Geyser, Plant, Scorch, TriggeredBomb, Zombie, and Player.


Member Data Documentation

SDL_Rect Object::pos [protected]
 

Todo:
Document this! Upper left logical position of the object (used for decisions)


The documentation for this class was generated from the following file:
Generated on Sun Feb 5 13:02:37 2006 for Lost Penguins by doxygen 1.3.8