![]() |
Dragonfly
4.4
A text-based game engine
|
Public Member Functions | |
Object () | |
virtual | ~Object () |
void | setId (int new_id) |
int | getId () const |
void | setType (std::string new_type) |
std::string | getType () const |
virtual void | setPosition (Vector new_position) |
Vector | getPosition () const |
virtual int | eventHandler (const Event *p_event) |
bool | isSolid () const |
int | setSolidness (Solidness new_solid) |
Solidness | getSolidness () const |
void | setNoSoft (bool new_no_soft=true) |
bool | getNoSoft () const |
void | setAvoidCollisions (bool new_avoid_collisions=true) |
bool | getAvoidCollisions () const |
int | setAltitude (int new_altitude) |
int | getAltitude () const |
void | setSpeed (float speed) |
float | getSpeed () const |
void | setDirection (Vector new_direction) |
Vector | getDirection () const |
void | setVelocity (Vector velocity) |
Vector | getVelocity () const |
void | setAcceleration (Vector new_acceleration) |
Vector | getAcceleration () const |
void | accelerate () |
Vector | predictPosition () |
void | pathTo (Vector position) |
void | pathTo (Object *p_o_target) |
void | moveTo (Vector position) |
void | doPathFollowing () |
int | setVisible (bool visible=true) |
bool | isVisible () const |
int | setActive (bool active=true) |
bool | isActive () const |
void | setBox (Box new_box) |
Box | getBox () const |
int | registerInterest (std::string event_type) |
int | unregisterInterest (std::string event_type) |
virtual void | draw () |
void | setSpriteName (std::string new_name) |
std::string | getSpriteName () const |
void | setSprite (Sprite *p_new_sprite, bool set_box=true) |
Sprite * | getSprite () const |
void | setCentered (bool centered=true) |
bool | isCentered () const |
void | setTransparency (char transparent=' ') |
char | getTransparency () const |
void | setSpriteIndex (int new_sprite_index) |
int | getSpriteIndex () const |
void | setSpriteSlowdown (int new_sprite_slowdown) |
int | getSpriteSlowdown () const |
void | setSpriteSlowdownCount (int new_sprite_slowdown_count) |
int | getSpriteSlowdownCount () const |
virtual std::string | serialize (bool all=false) |
virtual int | deserialize (std::string s) |
virtual bool | isModified (enum ObjectAttribute attribute) const |
virtual bool | isModified () const |
void | setShape (Shape new_shape) |
Shape | getShape () const |
void | setFollowPath (bool new_follow_path=true) |
bool | getFollowPath () const |
void | setPath (Path new_path) |
Path | getPath () const |
PathFind * | getPathFind () |
Private Attributes | |
int | m_id |
std::string | m_type |
bool | m_is_active |
bool | m_is_visible |
Box | m_box |
Vector | m_position |
Vector | m_direction |
float | m_speed |
Vector | m_acceleration |
std::string | sprite_name |
Sprite * | m_p_sprite |
bool | m_sprite_center |
char | m_sprite_transparency |
int | m_sprite_index |
int | m_sprite_slowdown |
int | m_sprite_slowdown_count |
int | m_altitude |
Solidness | m_solidness |
bool | m_no_soft |
int | m_event_count |
std::string | m_event_name [MAX_OBJ_EVENTS] |
bool | m_modified [ATTR_COUNT] |
Shape | m_shape |
PathFind * | m_p_path_find |
Path | m_path |
bool | m_follow_path |
bool | m_avoid_collisions |
df::Object::Object | ( | ) |
Construct Object.
Set default parameters and add to game world (WorldManager).
|
virtual |
Destroy Object.
Unregister for any interested events. Remove from game world (WorldManager).
void df::Object::accelerate | ( | ) |
|
virtual |
Deserialize string to become attributes.
Return 0 if no errors, else -1.
Reimplemented in df::ViewObject, df::TextEntry, and df::Button.
void df::Object::doPathFollowing | ( | ) |
If following a path, update path progress.
|
virtual |
Drawing accounts for centering & slowdown, and advances Sprite Frame.
Reimplemented in df::TextEntry, and df::ViewObject.
|
virtual |
Handle event (default only handles pathfinding).
Return 0 if ignored, else 1.
Reimplemented in df::ViewObject, df::Particle, df::TextEntry, df::Fraps, df::Button, df::Precipitation, df::Firework, df::SplashDragonfly, df::Pause, and df::Splash.
int df::Object::getAltitude | ( | ) | const |
Return altitude of Object.
bool df::Object::getAvoidCollisions | ( | ) | const |
Get "avoid collisions" (true - avoid collisions with HARD when moving).
bool df::Object::getFollowPath | ( | ) | const |
Returns true if following a path (note: is set in pathTo() method).
int df::Object::getId | ( | ) | const |
Get Object id.
bool df::Object::getNoSoft | ( | ) | const |
Get "no soft" setting of Object (true - cannot move onto SOFT Objects).
PathFind* df::Object::getPathFind | ( | ) |
Get object doing pathfinding.
Shape df::Object::getShape | ( | ) | const |
Get drawing shape.
float df::Object::getSpeed | ( | ) | const |
Get speed of Object.
int df::Object::getSpriteIndex | ( | ) | const |
Return index of current Sprite frame to be displayed.
std::string df::Object::getSpriteName | ( | ) | const |
Get Sprite name (in ResourceManager) for Object.
char df::Object::getTransparency | ( | ) | const |
Get Sprite transparency character (0 means none).
std::string df::Object::getType | ( | ) | const |
Get type identifier of Object.
bool df::Object::isActive | ( | ) | const |
Return activeness of Object.
Objects not active are not acted upon by engine.
|
virtual |
Return true if attribute modified since last serialize.
|
virtual |
Return true if any attribute modified since last serialize.
Reimplemented in df::ViewObject, df::TextEntry, and df::Button.
bool df::Object::isSolid | ( | ) | const |
Return True if Object is HARD or SOFT, else false.
bool df::Object::isVisible | ( | ) | const |
Return visibility of Object. Objects not visible are not drawn.
void df::Object::moveTo | ( | Vector | position | ) |
Set direction of Object towards position.
(Called when pathfinding).
void df::Object::pathTo | ( | Vector | position | ) |
Navigate Object from current position to target position using pathfinding.
Turns on avoid collisions.
void df::Object::pathTo | ( | Object * | p_o_target | ) |
Vector df::Object::predictPosition | ( | ) |
Predict Object position based on speed and direction.
Return predicted position.
int df::Object::registerInterest | ( | std::string | event_type | ) |
Register for interest in event.
Keeps track of manager and event. Return 0 if ok, else -1.
|
virtual |
Serialize attributes to single string.
e.g., "id:110,is_active:true, ... Only modified attributes are serialized (unless all is true). Clear modified[] array.
Reimplemented in df::ViewObject, df::TextEntry, and df::Button.
int df::Object::setActive | ( | bool | active = true | ) |
Set activeness of Object.
Objects not active are not acted upon by engine. Return 0 if ok, else -1.
int df::Object::setAltitude | ( | int | new_altitude | ) |
Set altitude of Object, with checks for range [0, MAX_ALTITUDE].
Return 0 if ok, else -1.
void df::Object::setAvoidCollisions | ( | bool | new_avoid_collisions = true | ) |
Set "avoid collisions" (true - avoid collisions with HARD when moving).
void df::Object::setCentered | ( | bool | centered = true | ) |
void df::Object::setFollowPath | ( | bool | new_follow_path = true | ) |
Set follow_path (note: is also set in pathTo() method).
If path defined, start moving to first node.
void df::Object::setId | ( | int | new_id | ) |
Set Object id.
void df::Object::setNoSoft | ( | bool | new_no_soft = true | ) |
Set "no soft" setting of Object (true - cannot move onto SOFT Objects).
|
virtual |
Set position of Object.
Reimplemented in df::ViewObject.
void df::Object::setShape | ( | Shape | new_shape | ) |
Set drawing shape.
int df::Object::setSolidness | ( | Solidness | new_solid | ) |
Set solidness of Object, with checks for consistency.
Return 0 if ok, else -1.
void df::Object::setSpeed | ( | float | speed | ) |
Set speed of Object.
void df::Object::setSprite | ( | Sprite * | p_new_sprite, |
bool | set_box = true |
||
) |
void df::Object::setSpriteIndex | ( | int | new_sprite_index | ) |
Set index of current Sprite frame to be displayed.
void df::Object::setSpriteName | ( | std::string | new_name | ) |
Set Sprite name (in ResourceManager) for Object.
void df::Object::setSpriteSlowdown | ( | int | new_sprite_slowdown | ) |
Slows down sprite animations.
Slowdown value in multiples of GameManager frame time.
void df::Object::setTransparency | ( | char | transparent = ' ' | ) |
Set Sprite transparency character (0 means none).
void df::Object::setType | ( | std::string | new_type | ) |
Set type identifier of Object.
int df::Object::setVisible | ( | bool | visible = true | ) |
Set visibility of Object.
Objects not visible are not drawn. Return 0 if ok, else -1.
int df::Object::unregisterInterest | ( | std::string | event_type | ) |
Unregister for interest in event.
Return 0 if ok, else -1.
|
private |
Acceleration vector.
|
private |
0 to MAX_ALTITUDE (higher drawn on top).
|
private |
True if should avoid collisions with HARD.
|
private |
Direction vector.
|
private |
Number of events of interest.
|
private |
Names of events interested in.
|
private |
True if following path.
|
private |
Unique game engine defined identifier.
|
private |
If false, Object not acted upon.
|
private |
If true, Object gets drawn.
|
private |
Mod. attrib. since last serialize().
|
private |
True if won't move on SOFT Objects.
|
private |
If following path, holds path information.
|
private |
Position in game world.
|
private |
Basic geometric shape to draw.
|
private |
Object speed in direction.
|
private |
True if sprite centered on position.
|
private |
Current index frame for sprite.
|
private |
Slowdown rate (1 = no slowdown, 0 = stop).
|
private |
Slowdown counter.
|
private |
Sprite transparent character (0 if none).
|
private |
Game-programmer defined identification.
|
private |
Sprite name in ResourceManager.