Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2006, 3:19:40 PM (18 years ago)
Author:
marcscha
Message:

weapon, collision, particles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10043 r10064  
    8484{
    8585  this->setPlayer(NULL);
     86  delete this->emitter;
    8687}
    8788
     
    135136  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    136137  this->registerObject(this, SpaceShip::_objectList);
    137 
     138  this->toList(OM_GROUP_00);
    138139  PRINTF(4)("SPACESHIP INIT\n");
    139140
     
    207208  electronicTH      = .7 * electronicMax; // 30% of eDamage can be handled by the ship
    208209
    209   /*
    210   this->addWeapon(wpLeft, 1, 0);
    211   this->addWeapon(wpRight,1 ,1);
    212   //this->addWeapon(cannon, 0, 6);
    213 
    214   this->getWeaponManager().changeWeaponConfig(1);
    215   */
    216210
    217211  this->loadModel("models/ships/mantawing.obj");
     
    220214  bForward = bBackward = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bFire = bSecFire = false;
    221215 
    222   /*
    223   xMouse = yMouse = 0;
    224   yInvert = 1;
    225   mouseSensitivity = 0.001;
    226   airViscosity = 0.9;
    227   controlVelocityX = 25;
    228   controlVelocityY = 150;
    229   shipInertia = 1.5;
    230   */
    231   //  cycle = 0.0;
    232216
    233217  this->setHealthMax(shieldMax);
     
    237221
    238222  // camera - issue
    239   //this->cameraNode = State::getCameraNode();
    240223  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
    241224  this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
    242225
    243   /*
    244   this->velocity = this->getAbsDirX()*travelSpeed;
    245   this->mouseDir = this->getAbsDir();
    246   this->pitchDir = this->getAbsDir();
    247   */
    248 
    249 
    250   //   GLGuiButton* button = new GLGuiPushButton();
    251   //    button->show();
    252   //    button->setLabel("orxonox");
    253   //    button->setBindNode(this);
    254   //     GLGuiBar* bar = new GLGuiBar();
    255   //     bar->show();
    256   //     bar->setValue(7.0);
    257   //     bar->setMaximum(10);
    258   //     bar->setSize2D( 20, 100);
    259   //     bar->setAbsCoor2D( 10, 200);
     226
    260227
    261228  //add events to the eventlist
     
    276243  this->weaponMan.setSlotCount(6);
    277244
    278   this->weaponMan.setSlotPosition(0, Vector(-2.6, .1, -3.0));
     245  this->weaponMan.setSlotPosition(0, Vector(-2.6, 0, -3.0));
    279246  this->weaponMan.setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    280247
    281   this->weaponMan.setSlotPosition(1, Vector(-2.6, .1, 3.0));
     248  this->weaponMan.setSlotPosition(1, Vector(-2.6, 0, 3.0));
    282249  this->weaponMan.setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    283250
    284   this->weaponMan.setSlotPosition(2, Vector(-1.5, .5, -.5));
     251  this->weaponMan.setSlotPosition(2, Vector(-1.5, 0, -.5));
    285252  this->weaponMan.setSlotDirection(2, Quaternion(-M_PI_4*.5, Vector(1,0,0)));
    286253
    287   this->weaponMan.setSlotPosition(3, Vector(-1.5, .5, .5));
     254  this->weaponMan.setSlotPosition(3, Vector(-1.5, 0, .5));
    288255  this->weaponMan.setSlotDirection(3, Quaternion(M_PI_4*.5, Vector(1,0,0)));
    289256
    290   this->weaponMan.setSlotPosition(4, Vector(-1.5, -.5, .5));
     257  this->weaponMan.setSlotPosition(4, Vector(-1.5, 0, .5));
    291258  this->weaponMan.setSlotDirection(4, Quaternion(-M_PI_4*.5+M_PI, Vector(1,0,0)));
    292259
    293   this->weaponMan.setSlotPosition(5, Vector(-1.5, -.5, -.5));
     260  this->weaponMan.setSlotPosition(5, Vector(-1.5, 0, -.5));
    294261  this->weaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    295262
     
    314281  this->secWeaponMan.setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0)));
    315282
    316   //
    317   //   this->getWeaponManager().setSlotPosition(8, Vector(-2.5, -0.3, -2.0));
    318   //   this->getWeaponManager().setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0)));
    319   //
    320   //   this->getWeaponManager().setSlotPosition(9, Vector(-2.5, -0.3, 2.0));
    321   //   this->getWeaponManager().setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0)));:
    322283
    323284  this->weaponMan.getFixedTarget()->setParent(this);
     
    335296  this->burstEmitter->setRelCoor(-1, .5, 0);
    336297  this->burstEmitter->setName("SpaceShip_Burst_emitter");
     298  this->burstEmitter->setEmissionRate(200);
    337299
    338300  this->burstSystem = new SpriteParticles(1000);
     
    340302  this->burstSystem->setName("SpaceShip_Burst_System");
    341303  ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
    342   this->burstSystem->setLifeSpan(1.0, .3);
     304  this->burstSystem->setLifeSpan(0.4, .3);
    343305  this->burstSystem->setRadius(0.0, 1.0);
    344306  this->burstSystem->setRadius(0.05, 1.0);
    345   this->burstSystem->setRadius(.5, .8);
     307  this->burstSystem->setRadius(.5, .6);
    346308  this->burstSystem->setRadius(1.0, 0);
    347309  this->burstSystem->setColor(0.0, .7,.7,1,.7);
     
    350312  this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    351313
    352   /*
    353   registerVar( new SynchronizeableQuaternion( &mouseDir, &mouseDir, "mousedir", PERMISSION_OWNER ) );
    354   registerVar( new SynchronizeableBool( &bUp, &bUp, "bUp", PERMISSION_OWNER ) );
    355   registerVar( new SynchronizeableBool( &bDown, &bDown, "bDown", PERMISSION_OWNER ) );
    356   registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) );
    357   registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) );
    358   registerVar( new SynchronizeableBool( &bAscend, &bAscend, "bAscend", PERMISSION_OWNER ) );
    359   registerVar( new SynchronizeableBool( &bDescend, &bDescend, "bDescend", PERMISSION_OWNER ) );
    360   registerVar( new SynchronizeableBool( &bRollL, &bRollL, "bRollL", PERMISSION_OWNER ) );
    361   registerVar( new SynchronizeableBool( &bRollR, &bRollR, "bRollR", PERMISSION_OWNER ) );
    362   */
     314  this->emitter = NULL;
    363315
    364316  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    369321  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
    370322  registerVar( new SynchronizeableBool( &bFire, &bFire, "bSecFire", PERMISSION_OWNER));
    371 
    372323  registerVar( new SynchronizeableVector( &velocity, &velocity, "velocity", PERMISSION_MASTER_SERVER ) );
    373324
     
    404355}
    405356
    406 /*
    407 void SpaceShip::setTravelHeight(float travelHeight)
    408 {
    409   if (this->toTravelHeight == NULL)
    410     this->toTravelHeight = new float;
    411   *this->toTravelHeight = travelHeight;
    412 }
    413 */
    414 
    415 /*
    416 void SpaceShip::setTravelDistance(const Vector2D& distance)
    417 {
    418   this->travelDistance = distance;
    419 }
    420 
    421 void SpaceShip::setTravelDistance(float x, float y)
    422 {
    423   this->setTravelDistance(Vector2D(x, y));
    424 }
    425 */
    426 
    427 
    428 
    429357void SpaceShip::reset()
    430358{
     
    441369{
    442370  this->secWeaponMan.showCrosshair();
     371  this->toList( OM_GROUP_01 );
    443372  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    444373  //this->attachCamera();
     
    449378{
    450379  this->secWeaponMan.hideCrosshair();
     380  this->toList(OM_GROUP_00);
    451381  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    452382  //this->detachCamera();
     
    466396*/
    467397void SpaceShip::leftWorld ()
    468 {}
     398{/*
     399  this->emitter->stop();
     400  delete this->emitter;
     401  delete this->explosionParticles; */
     402}
    469403
    470404WorldEntity* ref = NULL;
     
    603537
    604538}
    605 
    606 /*
    607 void SpaceShip::calculateVelocity (float time)
    608 {
    609   Vector accel(0.0, 0.0, 0.0);
    610   /* calculate the direction in which the craft is heading  */
    611   /*
    612   if( this->bUp )
    613   {
    614     accel += (this->getAbsDirX())*acceleration;
    615 
    616   }
    617 
    618   if( this->bDown )
    619   {
    620     accel -= (this->getAbsDirX())*0.5*acceleration;
    621 
    622   }
    623 
    624   if( this->bLeft)
    625   {
    626     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    627   }
    628   if( this->bRight)
    629   {
    630     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    631   }
    632 
    633 
    634   if( this->bRollL)
    635   {
    636     mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    637   }
    638   if( this->bRollR)
    639   {
    640     mouseDir *= Quaternion(time*2, Vector(1,0,0));
    641 
    642   }
    643   if (this->bAscend )
    644   {
    645     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    646   }
    647   if (this->bDescend )
    648   {
    649     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    650   }
    651 
    652   velocity += accel*time*10;
    653 
    654 }
    655 */
    656539
    657540/**
     
    689572{
    690573  PRINTF(0)("spaceship destroy\n");
     574
     575  this->explosionParticles = new SpriteParticles(1000);
     576  this->explosionParticles->setName("MBoltExplosionParticles");
     577  this->explosionParticles->setLifeSpan(.5, .3);
     578  this->explosionParticles->setRadius(0.0, 10.0);
     579  this->explosionParticles->setRadius(.5, 6.0);
     580  this->explosionParticles->setRadius(1.0, 3.0);
     581  this->explosionParticles->setColor(0.0, 1,1,0,.9);
     582  this->explosionParticles->setColor(0.5, .8,.8,0,.5);
     583  this->explosionParticles->setColor(1.0, .8,.8,.7,.0);
     584
     585  this->emitter = new DotEmitter(100000, 0, 0);
     586  this->emitter->setParent(this);
     587  this->emitter->setSpread(M_PI,M_PI);
     588  this->emitter->setEmissionRate(50.0);
     589  this->emitter->setEmissionVelocity(50.0);
     590
     591  this->emitter->setSystem(this->explosionParticles);
     592
     593  this->emitter->setSpread(50);
     594  this->emitter->setEmissionRate(50.0);
     595  this->emitter->setEmissionVelocity(50.0);
     596  this->updateNode(0);
     597
     598  this->toList(OM_DEAD);
    691599}
    692600
    693601void SpaceShip::respawn( )
    694602{
    695   toList( OM_PLAYERS );
     603  toList( OM_GROUP_00 );
    696604}
    697605
    698606
    699607void SpaceShip::damage(float pDamage, float eDamage){
    700 if( this->shieldActive) {
     608  PRINTF(0)("ship hit");
     609  printf("Shit hit");
     610  if( this->shieldActive) {
    701611    if( this->shieldCur > pDamage) {
    702612      this->shieldCur = this->shieldCur - pDamage;
     
    717627  }
    718628  if( this->armorCur <= 0) { /* FIXME implement shipcrash*/ }
     629    this->destroy(this);
    719630}
    720631
Note: See TracChangeset for help on using the changeset viewer.