00001 /****************************************************************************** 00002 * Wormux is a convivial mass murder game. 00003 * Copyright (C) 2001-2004 Lawrence Azzoug. 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00018 ****************************************************************************** 00019 *****************************************************************************/ 00020 00021 #ifndef MOVEMENT_H 00022 #define MOVEMENT_H 00023 #include <map> 00024 #include <vector> 00025 #include "../graphic/sprite.h" 00026 #include "../tool/point.h" 00027 #include "../tool/xml_document.h" 00028 00029 class member_mvt 00030 { // Position of a member relative to its superior one 00031 double angle_rad; // angle in radian 00032 public: 00033 Point2f pos; 00034 Point2f scale; 00035 /* SetAngle take radian values */ 00036 inline void SetAngle(double angle) 00037 { 00038 while(angle_rad > 2*M_PI) 00039 angle_rad -= 2 * M_PI; 00040 while(angle_rad <= -2*M_PI) 00041 angle_rad += 2 * M_PI; 00042 angle_rad = angle; 00043 } 00044 /* GetAngle returns radian values */ 00045 inline const double &GetAngle() { return angle_rad; } 00046 float alpha; 00047 bool follow_crosshair; 00048 bool follow_half_crosshair; 00049 bool follow_speed; 00050 bool follow_direction; 00051 member_mvt() { pos.x = pos.y = angle_rad = follow_crosshair = follow_half_crosshair 00052 = follow_speed = follow_direction = 0; 00053 alpha = scale.x = scale.y = 1.0;}; 00054 }; 00055 00056 class Movement 00057 { 00058 typedef std::map<std::string, struct member_mvt> member_def; // Describe the position of each member for a given frame 00059 00060 public: 00061 std::vector<member_def> frames; 00062 bool always_moving; 00063 int speed; 00064 uint test_left, test_right, test_top, test_bottom; 00065 00066 std::string type; 00067 00068 ~Movement(); 00069 Movement(xmlpp::Element *xml); 00070 }; 00071 00072 #endif //MEMBER_H