Changeset 6804 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Jan 28, 2006, 11:29:03 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/creatures/md2_creature.cc
r6561 r6804 39 39 40 40 CREATE_FACTORY(MD2Creature, CL_MD2_CREATURE); 41 42 /**43 * creates the controlable MD2Creature44 */45 MD2Creature::MD2Creature()46 {47 this->init();48 }49 41 50 42 /** … … 231 223 void MD2Creature::collidesWith(WorldEntity* entity, const Vector& location) 232 224 { 233 if (entity->isA(CL_TURRET_POWER_UP) ) 234 { 235 this->ADDWEAPON(); 236 } 237 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 225 238 226 } 239 227 … … 254 242 void MD2Creature::tick (float time) 255 243 { 244 Playable::tick(time); 256 245 if( likely(this->getModel(0) != NULL)) 257 246 ((MD2Model*)this->getModel(0))->tick(time); … … 284 273 this->setAbsDir(mouseDirX); 285 274 this->cameraConnNode.setRelDir(mouseDirY); 286 287 this->getWeaponManager()->tick(time);288 // weapon system manipulation289 this->weaponAction();290 275 } 291 276 … … 348 333 349 334 350 /**351 * weapon manipulation by the player352 */353 void MD2Creature::weaponAction()354 {355 if( this->bFire)356 {357 this->getWeaponManager()->fire();358 }359 }360 335 361 336 /** … … 364 339 void MD2Creature::process(const Event &event) 365 340 { 341 Playable::process(event); 366 342 if( event.type == SDLK_a) 367 343 this->bStrafeL = event.bPressed; 368 344 else if( event.type == SDLK_d) 369 345 this->bStrafeR = event.bPressed; 370 else if( event.type == KeyMapper::PEV_FIRE1)371 this->bFire = event.bPressed;372 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)373 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;374 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)375 this->getWeaponManager()->previousWeaponConfig();376 346 else if( event.type == SDLK_w) 377 347 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); … … 390 360 } 391 361 } 392 393 #include "weapons/aiming_turret.h"394 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG395 void MD2Creature::ADDWEAPON()396 {397 Weapon* turret = NULL;398 399 if ((float)rand()/RAND_MAX < .1)400 {401 //if (this->getWeaponManager()->hasFreeSlot(2, WTYPE_TURRET))402 {403 turret = new Turret();404 this->getWeaponManager()->addWeapon(turret, 2);405 this->getWeaponManager()->changeWeaponConfig(2);406 }407 }408 else409 {410 //if (this->getWeaponManager()->hasFreeSlot(3))411 {412 turret = new AimingTurret();413 this->getWeaponManager()->addWeapon(turret, 3);414 415 this->getWeaponManager()->changeWeaponConfig(3);416 }417 }418 419 if(turret != NULL)420 {421 turret->setName("Turret");422 turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1);423 }424 } -
trunk/src/world_entities/creatures/md2_creature.h
r6561 r6804 19 19 public: 20 20 21 MD2Creature();22 21 MD2Creature(const char* fileName); 23 MD2Creature(const TiXmlElement* root );22 MD2Creature(const TiXmlElement* root = NULL); 24 23 virtual ~MD2Creature(); 25 24 26 void init();27 25 virtual void loadParams(const TiXmlElement* root); 28 26 … … 42 40 43 41 private: 42 void init(); 44 43 45 44 void calculateVelocity(float time); 46 void weaponAction();47 48 // !! temporary !!49 void ADDWEAPON();50 45 51 46 bool bUp; //!< up button pressed. -
trunk/src/world_entities/playable.cc
r6710 r6804 38 38 // the reference to the Current Player is NULL, because we dont have one at the beginning. 39 39 this->currentPlayer = NULL; 40 41 this->bFire = false; 40 42 41 43 this->setSynchronized(true); … … 201 203 } 202 204 205 /** 206 * @brief ticks a Playable 207 * @param dt: the passed time since the last Tick 208 */ 209 void Playable::tick(float dt) 210 { 211 this->weaponMan->tick(dt); 212 if (this->bFire) 213 weaponMan->fire(); 214 } 215 216 217 /** 218 * @brief processes Playable events. 219 * @param event the Captured Event. 220 */ 221 void Playable::process(const Event &event) 222 { 223 if( event.type == KeyMapper::PEV_FIRE1) 224 this->bFire = event.bPressed; 225 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed) 226 { 227 this->nextWeaponConfig(); 228 } 229 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed) 230 this->previousWeaponConfig(); 231 } 232 233 203 234 204 235 void Playable::attachCamera() … … 210 241 211 242 243 244 212 245 void Playable::detachCamera() 213 246 { -
trunk/src/world_entities/playable.h
r6568 r6804 25 25 { 26 26 public: 27 Playable();28 27 virtual ~Playable(); 29 28 … … 49 48 50 49 virtual void collidesWith(WorldEntity* entity, const Vector& location); 51 virtual void process(const Event &event) = 0;50 virtual void process(const Event &event); 52 51 53 52 virtual void tick(float dt); 54 53 55 54 /** @return a List of Events in PEV_* sytle */ … … 57 56 58 57 protected: 58 Playable(); 59 59 60 void registerEvent(int eventType); 60 61 void unregisterEvent(int eventType); … … 66 67 Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL 67 68 69 bool bFire; //!< If the Ship is firing. 70 68 71 }; 69 72 -
trunk/src/world_entities/space_ships/helicopter.cc
r6724 r6804 124 124 125 125 //cycle = 0.0; 126 126 127 127 // cameraissue 128 128 this->cameraNode.setParent(this); 129 129 this->cameraNode.setParentMode(PNODE_ALL); 130 131 130 131 132 132 // rotors 133 133 this->topRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 134 134 this->tailRotor.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); 135 135 136 136 this->topRotor.setParent(this); 137 137 this->tailRotor.setParent(this); 138 138 139 139 this->topRotor.setRelCoor(Vector(-0.877,0.627,0)); 140 140 this->tailRotor.setRelCoor(Vector(-4.43,0.297,0.068)); 141 141 this->tailRotor.setAbsDir(Quaternion(M_PI_2,Vector(1,0,0))); 142 142 143 143 this->loadModel("models/ships/rotor.obj",1.0,3); 144 144 this->loadModel("models/ships/rotor.obj",0.2,4); … … 274 274 void Helicopter::tick (float time) 275 275 { 276 Playable::tick(time); 277 276 278 if( xMouse != 0 || yMouse != 0) 277 279 { … … 281 283 else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY; 282 284 } 283 285 284 286 // rotorrotation 285 287 this->topRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 286 288 this->tailRotor.shiftDir(Quaternion(time*10, Vector(0,1,0))); 287 289 288 290 // spaceship controlled movement 289 291 this->calculateVelocity(time); … … 293 295 // this is the air friction (necessary for a smooth control) 294 296 if(velocity.len() != 0) velocity -= velocity*0.1; 295 297 296 298 //travelSpeed = velocity.len(); 297 299 … … 301 303 this->shiftCoor(getAbsDirY()*rotorspeed); 302 304 */ 303 305 304 306 /* 305 307 //hoover effect … … 316 318 this->shiftCoor (move); 317 319 //this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0))); 318 319 this->getWeaponManager()->tick(time);320 // weapon system manipulation321 this->weaponAction();322 320 } 323 321 … … 338 336 //this->shiftCoor(this->getAbsDirX()); 339 337 //accel -= this->getAbsDirY(); 340 338 341 339 accel += Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z); 342 340 if((this->getAbsDirX()).y >= -0.1) rotValZ -= time; … … 351 349 //this->shiftCoor((this->getAbsDirX())*-1); 352 350 //accel -= this->getAbsDirY(); 353 351 354 352 accel -= Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z); 355 353 rotValZ += time; … … 365 363 //accel -= this->getAbsDirY(); 366 364 //velocityDir.normalize(); 367 365 368 366 accel -= Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z); 369 367 rotValX -= time; … … 379 377 //accel += this->getAbsDirY(); 380 378 //velocityDir.normalize(); 381 379 382 380 accel += Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z); 383 381 rotValX += time; … … 446 444 { 447 445 WorldEntity::draw(); 448 446 449 447 glMatrixMode(GL_MODELVIEW); 450 448 glPushMatrix(); … … 474 472 } 475 473 476 477 /**478 * weapon manipulation by the player479 */480 void Helicopter::weaponAction()481 {482 if( this->bFire)483 {484 this->getWeaponManager()->fire();485 }486 }487 488 474 /** 489 475 * @todo switch statement ?? … … 491 477 void Helicopter::process(const Event &event) 492 478 { 493 479 Playable::process(event); 494 480 495 481 if( event.type == KeyMapper::PEV_LEFT) … … 497 483 else if( event.type == KeyMapper::PEV_RIGHT) 498 484 this->bRight = event.bPressed; 499 else if( event.type == KeyMapper::PEV_FIRE1)500 this->bFire = event.bPressed;501 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)502 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;503 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)504 this->getWeaponManager()->previousWeaponConfig();505 485 else if( event.type == SDLK_e) 506 486 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); … … 517 497 518 498 this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))); 519 499 520 500 Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)); 521 501 522 502 523 503 if ((this->cameraNode.getAbsDirY()).y < 0.5) 524 504 { -
trunk/src/world_entities/space_ships/helicopter.h
r6724 r6804 21 21 virtual ~Helicopter(); 22 22 23 void init();24 23 virtual void loadParams(const TiXmlElement* root); 25 24 … … 40 39 41 40 private: 41 void init(); 42 42 void calculateVelocity(float time); 43 void weaponAction();44 43 45 44 // !! temporary !! … … 63 62 int controlVelocityY; 64 63 //float cycle; //!< hovercycle 65 64 66 65 PNode topRotor; 67 66 PNode tailRotor; 68 67 69 68 PNode cameraNode; 70 69 -
trunk/src/world_entities/space_ships/hover.cc
r6803 r6804 252 252 * @param time The timespan passed since last update 253 253 */ 254 void Hover::tick (float time) 255 { 254 void Hover::tick (float dt) 255 { 256 Playable::tick(dt); 257 256 258 if( xMouse != 0 || yMouse != 0) 257 259 { … … 263 265 264 266 // spaceship controlled movement 265 this->calculateVelocity( time);266 267 Vector move = (velocity)* time;267 this->calculateVelocity(dt); 268 269 Vector move = (velocity)*dt; 268 270 269 271 // this is the air friction (necessary for a smooth control) … … 271 273 this->shiftCoor (move); 272 274 273 this->getWeaponManager()->tick(time);274 // weapon system manipulation275 this->weaponAction();276 275 } 277 276 … … 400 399 { 401 400 Vector tmpRot; 402 403 401 WorldEntity::draw(); 404 402 … … 463 461 void Hover::process(const Event &event) 464 462 { 465 463 Playable::process(event); 466 464 467 465 if( event.type == KeyMapper::PEV_LEFT) … … 469 467 else if( event.type == KeyMapper::PEV_RIGHT) 470 468 this->bRight = event.bPressed; 471 else if( event.type == KeyMapper::PEV_FIRE1)472 this->bFire = event.bPressed;473 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)474 this->getWeaponManager()->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;475 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)476 this->getWeaponManager()->previousWeaponConfig();477 469 else if( event.type == SDLK_e) 478 470 this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0); -
trunk/src/world_entities/space_ships/space_ship.cc
r6803 r6804 306 306 void SpaceShip::tick (float time) 307 307 { 308 this->getWeaponManager()->tick(time); 309 // weapon system manipulation 310 this->weaponAction(); 308 Playable::tick(time); 311 309 312 310 if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() ) … … 464 462 465 463 /** 466 * weapon manipulation by the player467 */468 void SpaceShip::weaponAction()469 {470 if( this->bFire)471 {472 this->getWeaponManager()->fire();473 }474 }475 476 /**477 464 * @todo switch statement ?? 478 465 */ 479 466 void SpaceShip::process(const Event &event) 480 467 { 468 Playable::process(event); 469 481 470 if( event.type == KeyMapper::PEV_LEFT) 482 471 this->bRollL = event.bPressed; 483 472 else if( event.type == KeyMapper::PEV_RIGHT) 484 473 this->bRollR = event.bPressed; 485 else if( event.type == KeyMapper::PEV_FIRE1)486 this->bFire = event.bPressed;487 else if( event.type == KeyMapper::PEV_NEXT_WEAPON && event.bPressed)488 {489 this->nextWeaponConfig();//if( !event.bPressed) this->bWeaponChange = !this->bWeaponChange;490 }491 else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)492 this->previousWeaponConfig();493 474 else if( event.type == KeyMapper::PEV_UP) 494 475 this->bUp = event.bPressed; //this->shiftCoor(0,.1,0); -
trunk/src/world_entities/space_ships/space_ship.h
r6756 r6804 27 27 virtual ~SpaceShip(); 28 28 29 void init();30 29 virtual void loadParams(const TiXmlElement* root); 31 30 … … 47 46 48 47 private: 48 void init(); 49 49 50 50 void calculateVelocity(float time); 51 void weaponAction();52 51 53 52 // !! temporary !!
Note: See TracChangeset
for help on using the changeset viewer.