Changeset 4780 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Jul 2, 2005, 10:55:47 PM (19 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r4762 r4780 33 33 #include "event.h" 34 34 35 #include "crosshair.h" 36 35 37 using namespace std; 36 38 … … 48 50 the player.cc for debug also 49 51 */ 52 this->init(); 53 54 //weapons: 55 this->weaponMan = new WeaponManager(); 56 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 57 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 58 59 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 60 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 61 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 62 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 63 64 } 65 66 67 /** 68 \brief destructs the player, deletes alocated memory 69 */ 70 Player::~Player () 71 { 72 /* do not delete the weapons, they are contained in the pnode tree 73 and will be deleted there. 74 this only frees the memory allocated to save the list. 75 */ 76 delete this->weaponMan; 77 } 78 79 80 /** 81 \brief creates a new Player from Xml Data 82 \param root the xml element containing player data 83 84 \todo add more parameters to load 85 */ 86 Player::Player(const TiXmlElement* root) 87 { 88 this->init(); 89 this->loadParams(root); 90 91 //weapons: 92 this->weaponMan = new WeaponManager(); 93 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 94 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 95 96 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 97 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 98 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 99 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 100 101 102 new Crosshair(); 103 } 104 105 /** 106 * initializes a Player 107 */ 108 void Player::init() 109 { 50 110 this->setClassID(CL_PLAYER, "Player"); 51 111 … … 57 117 this->bWeaponChange = false; 58 118 acceleration = 10.0; 59 //weapons: 60 this->weaponMan = new WeaponManager(); 61 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 62 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 63 64 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 65 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 66 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 67 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 68 } 69 70 71 /** 72 \brief destructs the player, deletes alocated memory 73 */ 74 Player::~Player () 75 { 76 /* do not delete the weapons, they are contained in the pnode tree 77 and will be deleted there. 78 this only frees the memory allocated to save the list. 79 */ 80 delete this->weaponMan; 81 } 82 83 84 /** 85 \brief creates a new Player from Xml Data 86 \param root the xml element containing player data 87 88 \todo add more parameters to load 89 */ 90 Player::Player(const TiXmlElement* root) : WorldEntity(root) 91 { 92 this->setClassID(CL_PLAYER, "Player"); 93 94 this->weapons = new tList<Weapon>(); 95 this->activeWeapon = NULL; 96 /* 97 this is the debug player - actualy we would have to make a new 98 class derivated from Player for each player. for now, we just use 99 the player.cc for debug also 100 */ 101 travelSpeed = 15.0; 102 velocity = new Vector(); 103 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 104 bFire = false; 105 this->bWeaponChange = false; 106 acceleration = 10.0; 107 //weapons: 108 this->weaponMan = new WeaponManager(); 109 Weapon* wpRight = new TestGun(this, Vector(-2.6, 0.1, 3.0), Quaternion(), 0); 110 Weapon* wpLeft = new TestGun(this, Vector(-2.6, 0.1, -3.0), Quaternion(), 1); 111 112 this->weaponMan->addWeapon(wpRight, W_CONFIG0, W_SLOT0); 113 this->weaponMan->addWeapon(wpLeft, W_CONFIG1, W_SLOT1); 114 this->weaponMan->addWeapon(wpRight, W_CONFIG2); 115 this->weaponMan->addWeapon(wpLeft, W_CONFIG2); 119 } 120 121 122 /** 123 * 124 * @param root the XML-element to load the Player's properties from 125 */ 126 void Player::loadParams(const TiXmlElement* root) 127 { 128 static_cast<WorldEntity*>(this)->loadParams(root); 129 130 131 116 132 } 117 133 -
orxonox/trunk/src/world_entities/player.h
r4746 r4780 1 /*! 1 /*! 2 2 \file player.h 3 3 \brief Implements a basic controllable WorldEntity … … 22 22 { 23 23 friend class World; 24 24 25 25 public: 26 26 Player(); … … 28 28 virtual ~Player(); 29 29 30 void init(); 31 void loadParams(const TiXmlElement* root); 32 30 33 void addWeapon(Weapon* weapon); 31 34 void removeWeapon(Weapon* weapon); 32 35 33 36 virtual void postSpawn(); 34 37 virtual void leftWorld(); … … 36 39 virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags); 37 40 38 virtual void tick(float time); 41 virtual void tick(float time); 39 42 virtual void draw(); 40 43 … … 42 45 43 46 virtual void process(const Event &event); 44 47 45 48 private: 46 49 bool bUp; //!< up button pressed. … … 63 66 float travelSpeed; //!< the current speed of the player (to make soft movement) 64 67 float acceleration; //!< the acceleration of the player. 65 68 66 69 void move(float time); 67 70 void weapon(); 68 71 69 72 }; 70 73 -
orxonox/trunk/src/world_entities/weapons/crosshair.cc
r4779 r4780 17 17 18 18 #include "crosshair.h" 19 19 #include "event_handler.h" 20 20 using namespace std; 21 21 … … 23 23 /** 24 24 \brief standard constructor 25 \todo this constructor is not jet implemented - do it26 25 */ 27 26 Crosshair::Crosshair () … … 30 29 this->setName("Crosshair"); 31 30 31 EventHandler::getInstance()->subscribe(this, ES_GAME, EV_MOUSE_MOTION); 32 32 33 } 33 34 … … 35 36 /** 36 37 \brief standard deconstructor 37 38 38 */ 39 39 Crosshair::~Crosshair () … … 44 44 void Crosshair::process(const Event &event) 45 45 { 46 46 printf("wow\n"); 47 47 48 48 }
Note: See TracChangeset
for help on using the changeset viewer.