00001 #ifndef PERSON_H 00002 #define PERSON_H 00003 00004 00005 #include "Object.h" 00006 #include "Sprite.h" 00007 00008 typedef enum { JUMPING, STANDING, RUNNING, FALLING } State; 00009 00010 class Person : public Object 00011 { 00012 public: 00013 00014 //Person(); 00015 Person(List* personInfo, int x, int y); 00016 void draw(); 00017 void collide( Object* o ); 00018 virtual void update(); 00019 void jump(xDirection xDir); 00020 void jumpReset(); 00021 void crouch(); 00022 void uncrouch(); 00023 void shoot(); 00024 00025 void load(List *personInfo); 00026 00027 void setVelocity(int x, int y) {_xVelocity = x; _yVelocity = y;} 00028 00029 int getHealth() {return _health;} 00030 void addHealth(int dHealth) {_health += dHealth;} 00031 00032 //static Person * load(List* personInfo, int x, int y); 00033 00034 //void move(int x, int y); 00035 void incrVelocity(int xVel, int yVel); 00036 00037 00038 void setXDirection(xDirection xDir){_prevXDirection = _xDirection; _xDirection = xDir;}; 00039 int getAccel(); 00040 00041 00042 void aim( yDirection direction){_yDirection = direction;}; 00043 00044 protected: 00045 virtual void die(); 00046 00047 bool touchingAbove(); 00048 bool touchingBelow(); 00049 bool touchingLeft(); 00050 bool touchingRight(); 00051 00052 int _xVelocity; 00053 int _yVelocity; 00054 int _maxXVel; 00055 int _maxYVel; 00056 int _maxFallRate; 00057 00058 int _previousX; 00059 int _previousY; 00060 00061 xDirection _xDirection; 00062 xDirection _prevXDirection; 00063 yDirection _yDirection; 00064 State _state; 00065 00066 bool _crouching; 00067 /* 00068 True if the person is jumping 00069 */ 00070 //bool _jumping; 00071 00072 //int _wallJump; 00073 00074 /* true if the person is wallJumping 00075 */ 00076 //bool _wallJumping; 00077 00078 int _health; 00079 00080 int _gravity; 00081 int _accel; 00082 int _airAccel; 00083 double _groundDrag; 00084 double _airDrag; 00085 00086 int _waitShoot; 00087 int _framesSinceShoot; 00088 00089 int _jumpTimer; 00090 int _maxJumpTime; 00091 bool _jumpReset; 00092 bool _wallJumpReset; 00093 00094 int _bulletSpeed; 00095 00096 Sprite *_sprite; 00097 00098 }; 00099 00100 #endif