00001 #ifndef PERSON_H
00002 #define PERSON_H
00003
00004
00005 #include "Object.h"
00006 #include "Sprite.h"
00007 #include "ShowOneSprite.h"
00008
00009 class Weapon;
00010 class WeaponPunch;
00011
00012 typedef enum { JUMPING, STANDING, RUNNING, FALLING, WALLFALLING, CROUCHING, PUNCHING, DEAD } State;
00013
00014 class Person : public Object
00015 {
00016 public:
00017
00018
00019 Person(List* personInfo, int x, int y);
00020 ~Person();
00021 void draw();
00022 void collide( Object* o );
00023 virtual void update();
00024 void jump(xDirection xDir);
00025 void jumpReset();
00026 void crouch();
00027 void uncrouch();
00028 void shoot();
00029 virtual void setPos(int x, int y);
00030
00031 virtual Object *copy();
00032
00033 void load(List *personInfo, bool fromConstructor = true);
00034
00035 void setVelocity(int x, int y) {_xVelocity = x; _yVelocity = y;}
00036
00037 int getHealth() {return _health;}
00038 virtual void addHealth(int dHealth);
00039
00040
00041
00042
00043 void incrVelocity(int xVel, int yVel);
00044
00045
00046 void setXDirection(xDirection xDir){_prevXDirection = _xDirection; _xDirection = xDir;};
00047 int getAccel();
00048
00049 xDirection getXDirection() { return _xDirection; }
00050 yDirection getYDirection() { return _yDirection; }
00051
00052
00053 void aim( yDirection direction){_yDirection = direction;};
00054
00055 bool touchingAbove(int pels = 1);
00056 bool touchingBelow(int pels = 1);
00057 bool touchingLeft(int pels = 1);
00058 bool touchingRight(int pels = 1);
00059
00060 virtual bool invincible() { return _invincible;}
00061 virtual void setInvincible(bool inv) {_invincible = inv;}
00062
00063 virtual void die();
00064 virtual void live();
00065 protected:
00066
00067
00068 bool _invincible;
00069
00070 int _xVelocity;
00071 int _yVelocity;
00072 int _maxXVel;
00073 int _maxYVel;
00074 int _maxFallRate;
00075
00076 int _previousX;
00077 int _previousY;
00078
00079 xDirection _xDirection;
00080 xDirection _prevXDirection;
00081 yDirection _yDirection;
00082 State _state;
00083
00084 std::string _dropItem;
00085
00086 bool _crouching;
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 int _health;
00099
00100 int _gravity;
00101 int _accel;
00102 int _airAccel;
00103 double _groundDrag;
00104 double _airDrag;
00105
00106 int _jumpTimer;
00107 int _maxJumpTime;
00108 bool _jumpReset;
00109 bool _wallJumpReset;
00110
00111 int _wallFallTime;
00112
00113
00114 Weapon *_primaryWeapon;
00115 WeaponPunch *_punchWeapon;
00116 int _punchTimer;
00117
00118 ShowOneSprite *_sprite;
00119
00120 };
00121
00122 #endif