Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

characters_common.h

00001 #ifndef DEF_CHARACTERS_COMMON_H 00002 #define DEF_CHARACTERS_COMMON_H 1 00003 00004 #include "weapons.h" 00005 #include "objects_common.h" 00006 00007 //Falling, Landing 00008 #define T_IRR 2000 00009 #define V_KRIT 1000 00010 #define T_GRAV_EFFECT 10 00011 #define T_AI_EFFECT 20 00012 #define HSPEED_MULT 100 00013 00014 //Character states 00015 //facing: either left or right (not left) 00016 #define STATE_LEFT 0x00000001 00017 //in water 00018 #define STATE_WATER 0x00000004 00019 //falling 00020 #define STATE_FALL 0x00000008 00021 //Common Triggers 00022 #define STATE_ACT_1 0x00000010 00023 #define STATE_ACT_2 0x00000020 00024 #define STATE_ACT_3 0x00000040 00025 00026 //Special states 00027 #define STATE_RUN 0x00000080 00028 #define STATE_PRESS_LR 0x00000100 00029 #define STATE_PRESS_UD 0x00000200 00030 00031 00036 class Character : public Object { 00037 public: 00038 Character(Sint16 xpos=0, Sint16 ypos=0, const ParameterMap& param=ParameterMap()); 00039 virtual ~Character(); 00040 static ParameterMap default_parameters; 00041 Uint8 getHealth(); 00043 Sint16 getSpeed() const { 00044 return speed; 00045 } 00046 Sint16 setSpeed(Sint16 newspeed) { 00047 return speed=newspeed; 00048 } 00049 Sint16 addSpeed(Sint16 dspeed) { 00050 return speed+=dspeed; 00051 } 00052 Sint16 addHSpeed(Sint16 dspeed) { 00053 return hspeed+=dspeed; 00054 } 00056 00057 void setGravity(Sint16 setgravity) { 00058 gravity=setgravity; 00059 } 00060 void addGravity(Sint16 addgravity) { 00061 gravity+=addgravity; 00062 } 00064 00065 Uint16 addMaxSpeed(Sint16 dmax) { 00066 maxspeedx=max(0,maxspeedx+dmax); 00067 if (hspeed>maxspeedx) hspeed=maxspeedx; 00068 if (hspeed<-maxspeedx) hspeed=-maxspeedx; 00069 return maxspeedx; 00070 } 00071 Uint16 setMaxSpeed(Uint16 maxs) { 00072 maxspeedx=maxs; 00073 if (hspeed>maxspeedx) hspeed=maxspeedx; 00074 if (hspeed<-maxspeedx) hspeed=-maxspeedx; 00075 return maxspeedx; 00076 } 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 Hit checkMove(SDL_Rect& dest, bool tele=false, bool check=false); 00093 const std::set<Object *>& getEnter() const { 00094 return enter; 00095 } 00096 const std::set<Object *>& getTouch() const { 00097 return touch; 00098 } 00100 //VIRTUAL METHODS 00102 00103 00104 00105 00106 virtual void removedObject(Object*); 00110 virtual void updateAnimState(); 00111 virtual void resetAnimState() { 00112 Object::resetAnimState(); 00113 updateAnimState(); 00114 } 00115 //Define these for each character, the base function must be run for all derived classes 00116 virtual void idle(Uint16); 00119 virtual void fall(Uint16); 00120 //when it dies... 00121 virtual void die(); 00129 virtual Uint16 hit(Uint16 direction, Weapon& weap); 00131 protected: 00142 inline Hit checkHit(const SDL_Rect& dest, Object* destobj, bool tele=false) const; 00150 inline void updateRegions(std::set<Object *>& newtouch, std::set<Object *>& newenter); 00152 00153 00154 Uint8 setHealth(Uint8); 00157 Uint8 addHealth(Sint8); 00159 //crash into another object (default: ground) 00160 virtual void crash(Uint16 dir=DIR_DOWN); 00163 virtual Hit move(Uint16 dt, bool check=false); 00164 Uint8 health; 00165 Uint8 maxhealth; 00166 //maximal normal speed; 00167 Uint16 maxspeedx; 00168 Uint16 maxspeedy; 00169 //temporary speed (x direction) 00170 Sint16 hspeed; 00171 //current permanent speed (y direction) 00172 Sint16 speed; 00173 //current gravity 00174 Sint16 gravity; 00175 //temporary attributes 00176 Sint16 Dgrav; 00177 //Entered objects 00178 std::set<Object *> enter; 00179 //Touched objects 00180 std::set<Object *> touch; 00181 //dense types 00182 Uint16 dense_types; 00183 //enemy types 00184 Uint16 enemy_types; 00185 //current weapon (updated for each attack) 00186 Weapon weapon; 00188 00189 virtual void addTouch(std::set<Object *>&); 00191 virtual void addEnter(std::set<Object *>&); 00193 virtual void removeTouch(std::set<Object *>&); 00195 virtual void removeEnter(std::set<Object *>&); 00197 private: 00198 Uint16 dt_fall2; 00199 }; 00200 #endif

Generated on Sun Feb 5 13:02:35 2006 for Lost Penguins by doxygen 1.3.8