Claypool

Courses

Publications

Students

Projects

Service

Downloads

Misc


Dragonfly: Object Class Reference
Dragonfly 2.2
A text-based game engine
Public Member Functions | Protected Attributes | Private Attributes

Object Class Reference

The base object. More...

#include <Object.h>

Inheritance diagram for Object:
GameObject ViewObject Splash SplashDragonfly Fraps

List of all members.

Public Member Functions

void setId (int new_id)
int getId ()
void setType (string new_type)
string getType ()
void setBox (Box new_box)
Box getBox ()
void setPosition (Position new_pos)
Position getPosition ()
virtual int setPersistence (bool persistent)
 Set persistence of object. Returns 0.
bool isPersistent ()
 Return persistence of object.
virtual int setVisibility (bool visible)
 Set visibility of object.
bool isVisible ()
 Return visibility of object. Objects not visible are not drawn.
virtual int eventHandler (Event *p_event)
 Handle event (default is to ignore everything).
virtual void draw ()
 Draw single sprite frame.
void setSprite (Sprite *p_new_sprite)
 Set Sprite associated with this object to new one.
void setSprite (Sprite *p_new_sprite, bool set_box)
 Set object Sprite to new one.
SpritegetSprite ()
 Return pointer to Sprite associated with this object.
bool isCentered ()
 Indicates if sprite is centered at object Position (pos).
void setCentered (bool centered)
 Indicate sprite is to centered at object Position (pos).
int getSpriteIndex ()
 Return the index of current Sprite frame to be displayed.
void setSpriteIndex (int new_sprite_index)
 Set index of current Sprite frame to be displayed.
void setSpriteSlowdown (int new_sprite_slowdown)
 Slows down sprite animations.
int getSpriteSlowdown ()
void setSpriteSlowdownCount (int new_sprite_slowdown_count)
int getSpriteSlowdownCount ()

Protected Attributes

string type
 User-defined identification.
Position pos
 Position in the game world.
Spritep_sprite
 The sprite associated with this object.
bool sprite_center
 True if sprite is centered on object.
int sprite_index
 Current index frame for sprite.
int sprite_slowdown
 Slowdown rate (1 = no slowdown, 0 = stop).
int sprite_slowdown_count
 Slowdown counter.
Box box
 Box for sprite boundary & collisions.

Private Attributes

int id
 Globally unique id of object.
bool is_visible
 If true, object gets drawn.
bool is_persistent
 If true, object are active all levels.

Detailed Description

The base object.

< Objects need a location. Objects have a bounding box. Objects can handle events. Objects (often) have sprites.


Member Function Documentation

virtual void Object::draw ( ) [virtual]

Draw single sprite frame.

Drawing accounts for: centering, slowdown, advancing Sprite Frame (as appropriate for each).

Reimplemented in ViewObject.

virtual int Object::eventHandler ( Event p_event) [virtual]

Handle event (default is to ignore everything).

Return 0 if ignored, else 1

Reimplemented in Fraps, Splash, SplashDragonfly, and ViewObject.

bool Object::isPersistent ( )

Return persistence of object.

Persistent objects are active across all levels.

void Object::setSprite ( Sprite p_new_sprite)

Set Sprite associated with this object to new one.

Set bounding box to size of sprite.

void Object::setSprite ( Sprite p_new_sprite,
bool  set_box 
)

Set object Sprite to new one.

If set_box is true, set bounding box to size of Sprite.

void Object::setSpriteSlowdown ( int  new_sprite_slowdown)

Slows down sprite animations.

new_sprite_slowdown is in multiples of WorldManager frame time.

virtual int Object::setVisibility ( bool  visible) [virtual]

Set visibility of object.

Objects not visible are not drawn. Return 0.

Reimplemented in GameObject, and ViewObject.


The documentation for this class was generated from the following file:
 All Classes Functions Variables Friends