Movement Class Reference

#include <movement.h>

List of all members.

Public Member Functions

 ~Movement ()
 Movement (xmlpp::Element *xml)

Public Attributes

std::vector< member_defframes
bool always_moving
int speed
uint test_left
uint test_right
uint test_top
uint test_bottom
std::string type

Private Types

typedef std::map< std::string,
struct member_mvt
member_def


Detailed Description

Definition at line 56 of file movement.h.


Member Typedef Documentation

typedef std::map<std::string, struct member_mvt> Movement::member_def [private]

Definition at line 58 of file movement.h.


Constructor & Destructor Documentation

Movement::~Movement (  ) 

Definition at line 104 of file movement.cpp.

00105 {
00106 }

Movement::Movement ( xmlpp::Element *  xml  ) 

Definition at line 27 of file movement.cpp.

00028 {
00029   always_moving = false;
00030   XmlReader::ReadStringAttr( xml, "name", type);
00031   assert(type!="");
00032 
00033   speed = 15;
00034   XmlReader::ReadIntAttr(xml, "speed", speed);
00035 
00036   // Load the test rectangle
00037   test_left = test_right = test_top = test_bottom = 0;
00038   xmlpp::Element *collision_rect = XmlReader::GetMarker(xml, "collision_rect");
00039   if (collision_rect == NULL) return;
00040   XmlReader::ReadUintAttr(collision_rect, "left", test_left);
00041   XmlReader::ReadUintAttr(collision_rect, "right", test_right);
00042   XmlReader::ReadUintAttr(collision_rect, "top", test_top);
00043   XmlReader::ReadUintAttr(collision_rect, "bottom", test_bottom);
00044 
00045   xmlpp::Node::NodeList nodes = xml -> get_children("frame");
00046   xmlpp::Node::NodeList::iterator
00047     it=nodes.begin(),
00048     end=nodes.end();
00049 
00050   for (; it != end; ++it)
00051   {
00052     xmlpp::Element *elem = dynamic_cast<xmlpp::Element*> (*it);
00053     assert (elem != NULL);
00054     int frame_number;
00055     XmlReader::ReadIntAttr(elem, "number", frame_number);
00056 
00057     xmlpp::Node::NodeList nodes2 = elem -> get_children("member");
00058     xmlpp::Node::NodeList::iterator
00059       it2=nodes2.begin(),
00060       end2=nodes2.end();
00061 
00062     for (; it2 != end2; ++it2)
00063     {
00064       xmlpp::Element *elem2 = dynamic_cast<xmlpp::Element*> (*it2);
00065       std::string member_type;
00066       XmlReader::ReadStringAttr(elem2, "type", member_type);
00067 
00068       member_mvt mvt;
00069       int dx, dy;
00070       int angle_deg = 0;
00071       dx = dy = 0;
00072       double scale_x, scale_y, tmp_alpha;
00073       scale_x = scale_y = tmp_alpha = 1.0;
00074       XmlReader::ReadIntAttr(elem2, "dx", dx);
00075       XmlReader::ReadIntAttr(elem2, "dy", dy);
00076       XmlReader::ReadDoubleAttr(elem2, "scale_x", scale_x);
00077       XmlReader::ReadDoubleAttr(elem2, "scale_y", scale_y);
00078       XmlReader::ReadDoubleAttr(elem2, "alpha", tmp_alpha);
00079       XmlReader::ReadIntAttr(elem2, "angle", angle_deg);
00080       XmlReader::ReadBoolAttr(elem2, "follow_crosshair", mvt.follow_crosshair);
00081       XmlReader::ReadBoolAttr(elem2, "follow_half_crosshair", mvt.follow_half_crosshair);
00082       XmlReader::ReadBoolAttr(elem2, "follow_speed", mvt.follow_speed);
00083       XmlReader::ReadBoolAttr(elem2, "follow_direction", mvt.follow_direction);
00084       if(tmp_alpha < 0.0 || tmp_alpha > 1.0) tmp_alpha = 1.0;
00085       mvt.SetAngle(angle_deg * M_PI / 180);
00086       mvt.pos.x = dx;
00087       mvt.pos.y = dy;
00088       mvt.alpha = tmp_alpha;
00089       mvt.scale = Point2f(scale_x, scale_y);
00090 
00091       always_moving |= mvt.follow_crosshair;
00092       always_moving |= mvt.follow_half_crosshair;
00093       always_moving |= mvt.follow_speed;
00094       always_moving |= mvt.follow_direction;
00095 
00096       if((int)frames.size() <= frame_number)
00097         frames.resize(frame_number+1);
00098 
00099       frames[frame_number][member_type] = mvt;
00100     }
00101   }
00102 }

Here is the call graph for this function:


Member Data Documentation

bool Movement::always_moving

Definition at line 62 of file movement.h.

std::vector<member_def> Movement::frames

Definition at line 61 of file movement.h.

int Movement::speed

Definition at line 63 of file movement.h.

uint Movement::test_bottom

Definition at line 64 of file movement.h.

uint Movement::test_left

Definition at line 64 of file movement.h.

uint Movement::test_right

Definition at line 64 of file movement.h.

uint Movement::test_top

Definition at line 64 of file movement.h.

std::string Movement::type

Definition at line 66 of file movement.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:00:43 2007 for Wormux by  doxygen 1.4.7