00001 #ifndef PLAYER_H_INCLUDED
00002 #define PLAYER_H_INCLUDED
00003
00004 #include "time.h"
00005 #include <btBulletDynamicsCommon.h>
00006 #include "Horde3D.h"
00007
00008 #include "Vec3.h"
00009 #include "Physics.h"
00010 #include "Enemy.h"
00011 #include "Bullet.h"
00012 #include "IShootable.h"
00013
00014
00015 class Enemy;
00016 class Physics;
00017 class Bullet;
00018 class Game;
00019
00020 enum Weapon {
00021 CHAINGUN,
00022 BOLTER,
00023 UNSET_WEAPON
00024 };
00025
00026 class Player : public IShootable {
00027 private:
00028 btCapsuleShape* _capsule;
00029 btDefaultMotionState* _groundMotionState;
00030 H3DNode _cam2, _weaponChainGun, _weaponBolter, _gunfire, _gunFireLight;
00031 H3DRes _bulletRes;
00032 Weapon _currentWeaponType;
00033 float _curWeaponRateOfFire, _animationTime, _weaponRecoilFactor;
00034 clock_t _timeSinceLastBullet;
00035 std::vector<Bullet*> _shotBullets;
00036
00037 float _capsuleHeight, _bodyRadius, _levelBelowCapsule;
00038 float _rx, _ry;
00039 bool _debugMode, _wireframeMode;
00040 int _keys;
00041 int MOVE_FWD;
00042 int MOVE_LEFT;
00043 int MOVE_BACK;
00044 int MOVE_RIGHT;
00045 int MOVE_RUN;
00046 int FIRE_GUN;
00047 int MOVE_JUMP;
00048
00049 public:
00050 Player(Game* game, Physics* physics, H3DNode camera, const int id);
00051 ~Player();
00052 void hit();
00053 void update(float timeStep);
00054 Vec3 getPosition() const;
00055 const char* getCurrentWeaponName() const;
00056 void setKeyboardInput(const int key, bool pushed);
00057 void setMouseInput(float dX, float dY);
00058 void setMouseButtonInput(int button, bool action);
00059 void addReflectionCamera(H3DNode cam2);
00060 private:
00061 void move(const float zspeed, const float xspeed);
00062 bool castRayAndCorrectPosition(Vec3& calculatedCurrentPosition, Vec3& collisionPoint);
00063 IShootable* fireGun(Vec3 currentPosition, float xAngle, float yAngle);
00064 void setPosition(const Vec3 &newPosition);
00065 void changeWeapon(Weapon newWeapon);
00066 int calcShotsPerTimeStep(const float timeStep);
00067 void removeGunFire();
00068 void addGunFire(const float timeStep);
00069 };
00070
00071 #endif