Changeset 3746 in orxonox.OLD for orxonox/branches/levelloader/src/world_entities/player.cc
- Timestamp:
- Apr 7, 2005, 3:54:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/levelloader/src/world_entities/player.cc
r3605 r3746 20 20 #include "player.h" 21 21 22 #include "track_manager.h" 23 #include "objModel.h" 24 #include "resource_manager.h" 25 #include "weapon.h" 26 #include "test_gun.h" 27 #include "world.h" 28 29 #include "list.h" 22 30 #include "stdincl.h" 23 //#include "collision.h"24 #include "objModel.h"25 #include "list.h"26 #include "weapon.h"27 #include "track_manager.h"28 31 29 32 using namespace std; … … 35 38 \param isFree if the player is free 36 39 */ 37 Player::Player(bool isFree) : WorldEntity(isFree) 38 { 39 this->model = new OBJModel("../data/models/reaplow.obj"); 40 Player::Player() : WorldEntity() 41 { 40 42 this->weapons = new tList<Weapon>(); 41 43 this->activeWeapon = NULL; 42 44 /* 45 this is the debug player - actualy we would have to make a new 46 class derivated from Player for each player. for now, we just use 47 the player.cc for debug also 48 */ 49 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 43 50 travelSpeed = 15.0; 44 velocity = Vector();51 velocity = new Vector(); 45 52 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 46 53 bFire = false; 47 54 acceleration = 10.0; 55 //weapons: 56 Weapon* wp = new TestGun(this, new Vector(-1.1, 0.0, 2.6), new Quaternion()); 57 this->weapons->add(wp); 58 this->activeWeapon = wp; 48 59 } 49 60 … … 53 64 Player::~Player () 54 65 { 55 Weapon* w = this->weapons->enumerate(); 56 while( w != NULL) 57 { 58 delete w; 59 w = this->weapons->nextElement(); 60 } 66 /* do not delete the weapons, they are contained in the pnode tree 67 and will be deleted there. 68 this only frees the memory allocated to save the list. 69 */ 61 70 delete this->weapons; 62 63 //delete this->velocity;64 71 } 65 72 … … 94 101 string = grabParameter( root, "model"); 95 102 if( string != NULL) 96 this->model = new OBJModel( string);103 this->model = (Model*)ResourceManager::getInstance()->load(string, OBJ, RP_CAMPAIGN); 97 104 else 98 105 { 99 106 PRINTF0("Player is missing a proper 'model'\n"); 100 this->model = new OBJModel( "../data/models/reaplow.obj");107 this->model = (Model*)ResourceManager::getInstance()->load("models/reaplow.obj", OBJ, RP_CAMPAIGN); 101 108 } 102 109 if( this->model == NULL) … … 104 111 PRINTF0("Player model '%s' could not be loaded\n", string); 105 112 } 113 114 this->weapons = new tList<Weapon>(); 115 this->activeWeapon = NULL; 116 /* 117 this is the debug player - actualy we would have to make a new 118 class derivated from Player for each player. for now, we just use 119 the player.cc for debug also 120 */ 121 travelSpeed = 15.0; 122 velocity = new Vector(); 123 bUp = bDown = bLeft = bRight = bAscend = bDescend = false; 124 bFire = false; 125 acceleration = 10.0; 126 //weapons: 127 Weapon* wp = new TestGun(this, new Vector(-1.1, 0.0, 2.6), new Quaternion()); 128 this->weapons->add(wp); 129 this->activeWeapon = wp; 106 130 } 107 131 … … 192 216 void Player::tick (float time) 193 217 { 218 /* link tick to weapon */ 219 this->activeWeapon->tick(time); 194 220 // player controlled movement 195 this->move 221 this->move(time); 196 222 // weapon system manipulation 197 this-> fire();223 this->weapon(); 198 224 } 199 225 … … 214 240 //orthDirection = orthDirection.cross (direction); 215 241 216 if( this->bUp && this->getRelCoor() .x < 20)242 if( this->bUp && this->getRelCoor()->x < 20) 217 243 accel = accel+(direction*acceleration); 218 if( this->bDown && this->getRelCoor() .x > -5)244 if( this->bDown && this->getRelCoor()->x > -5) 219 245 accel = accel-(direction*acceleration); 220 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor() .z*2)246 if( this->bLeft && TrackManager::getInstance()->getWidth() > -this->getRelCoor()->z*2) 221 247 accel = accel - (orthDirection*acceleration); 222 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor() .z*2)248 if( this->bRight && TrackManager::getInstance()->getWidth() > this->getRelCoor()->z*2) 223 249 accel = accel + (orthDirection*acceleration); 224 250 if( this->bAscend ) … … 233 259 \brief weapon manipulation by the player 234 260 */ 235 void Player:: fire()236 { 237 if( this->bFire)261 void Player::weapon() 262 { 263 if( this->bFire) 238 264 { 239 265 if(this->activeWeapon != NULL) 240 266 this->activeWeapon->fire(); 241 267 } 242 if( this->bWeaponChange)268 if( this->bWeaponChange && this->weapons->getSize() > 1) 243 269 { 244 Weapon* w = this->weapons->enumerate(); 270 PRINTF(1)("changing the weapon of the player: deactivate old, activate new\n"); 271 this->activeWeapon->deactivate(); 272 //this->weapons->enumerate(); FIX: strang weapon change... 245 273 this->activeWeapon = this->weapons->nextElement(this->activeWeapon); 274 this->activeWeapon->activate(); 246 275 } 247 276 }
Note: See TracChangeset
for help on using the changeset viewer.