Dragonfly 4.19
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 int | 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 new_position) |
void | doPathFollowing () |
int | setVisible (bool new_visible=true) |
bool | isVisible () const |
int | setActive (bool new_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) |
int | setSprite (std::string sprite_label) |
void | setAnimation (Animation new_animation, bool set_box=true) |
Animation | getAnimation () const |
virtual int | draw () |
virtual std::string | serialize (std::string attr="") |
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 () |
std::string | toString () const |
Static Public Attributes | |
static int | max_id |
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 |
int | m_altitude |
Solidness | m_solidness |
Animation | m_animation |
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 and apply.
Return 0 if no errors, else -1.
Reimplemented in df::Button, df::Particle, df::TextEntry, and df::ViewObject.
void df::Object::doPathFollowing | ( | ) |
If following a path, update path progress.
|
virtual |
Draw Object: Animation and/or Shape.
Return 0 if ok, else -1.
Reimplemented in df::TextEntry, and df::ViewObject.
|
virtual |
Handle event (default only handles pathfinding).
Return 0 if ignored, else 1.
Reimplemented in df::Button, df::Firework, df::Fraps, df::NetworkNode, df::Particle, df::Pause, df::Precipitation, df::Splash, df::SplashDragonfly, df::TextEntry, and df::ViewObject.
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.
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 any attribute modified since last serialize.
Reimplemented in df::Button, df::TextEntry, and df::ViewObject.
|
virtual |
Return true if attribute modified since last serialize.
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 | new_position | ) |
Set direction of Object towards position.
(Called when pathfinding).
void df::Object::pathTo | ( | Object * | p_o_target | ) |
void df::Object::pathTo | ( | Vector | position | ) |
Navigate Object from current position to target position using pathfinding.
Turns on avoid collisions.
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 string.
e.g., "id:4,pos-x:2.2,pos-y:0.9...". Default ("") is only attributes modified since last serialize(). Can specify specific attribute(s) to serialize (modified or not). separated by commas. If attr is "ALL" then serialize all attributes (modified or not). Clear m_modified[] array for attributes serialized.
Reimplemented in df::Button, df::Particle, df::TextEntry, and df::ViewObject.
int df::Object::setActive | ( | bool | new_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::setAnimation | ( | Animation | new_animation, |
bool | set_box = true |
||
) |
void df::Object::setAvoidCollisions | ( | bool | new_avoid_collisions = true | ) |
Set "avoid collisions" (true - avoid collisions with HARD when moving).
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 |
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.
int df::Object::setSprite | ( | std::string | sprite_label | ) |
void df::Object::setType | ( | std::string | new_type | ) |
Set type identifier of Object.
int df::Object::setVisible | ( | bool | new_visible = true | ) |
Set visibility of Object.
Objects not visible are not drawn. Return 0 if ok, else -1.
std::string df::Object::toString | ( | ) | const |
Return base attributes as string.
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 |
Game programmer defined type.
|
static |
Monotonically increasing identifier.