Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2006, 4:08:04 PM (18 years ago)
Author:
marcscha
Message:

addition of local travel speed, removal of path hacks

File:
1 edited

Legend:

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

    r10096 r10098  
    141141  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    142142  this->registerObject(this, SpaceShip::_objectList);
    143   this->toList(OM_GROUP_00);
    144143  PRINTF(4)("SPACESHIP INIT\n");
    145144
    146145  //weapons:
    147   /*
     146 
    148147  Weapon* wpRight1 = new LightBlaster ();
    149148  wpRight1->setName( "LightBlaster");
     
    151150  Weapon* wpLeft1 = new LightBlaster ();
    152151  wpLeft1->setName( "LightBlaster");
    153   wpLeft1->setParent( this);*/
     152  wpLeft1->setParent( this);
    154153
    155154  Weapon* wpRight2 = new MediumBlaster ();
     
    159158  wpLeft2->setName( "MediumBlaster");
    160159  wpLeft2->setParent( this);
    161   /*
     160 
    162161  Weapon* wpRight3 = new HeavyBlaster ();
    163162  wpRight3->setName( "HeavyBlaster");
     
    165164  Weapon* wpLeft3 = new HeavyBlaster ();
    166165  wpLeft3->setName( "HeavyBlaster");
    167   wpLeft3->setParent( this);*/
     166  wpLeft3->setParent( this);
    168167
    169168  Weapon* cannon = new SwarmLauncher();
     
    172171
    173172
    174   //this->weaponMan.addWeapon( wpLeft1, 0, 0);
    175   //this->weaponMan.addWeapon( wpRight1, 0, 1);
     173  this->weaponMan.addWeapon( wpLeft1, 0, 0);
     174  this->weaponMan.addWeapon( wpRight1, 0, 1);
    176175  this->weaponMan.addWeapon( wpLeft2, 0, 2);
    177176  this->weaponMan.addWeapon( wpRight2, 0, 3);
    178   //this->weaponMan.addWeapon( wpLeft3, 0, 4);
    179   //this->weaponMan.addWeapon( wpRight3, 0, 5);
     177  this->weaponMan.addWeapon( wpLeft3, 0, 4);
     178  this->weaponMan.addWeapon( wpRight3, 0, 5);
    180179
    181180  this->secWeaponMan.addWeapon( cannon, 1, 0);
     
    184183  this->secWeaponMan.changeWeaponConfig(1);
    185184
    186   //wpRight1->requestAction(WA_ACTIVATE);
    187   //wpLeft1->requestAction(WA_ACTIVATE);
     185  wpRight1->requestAction(WA_ACTIVATE);
     186  wpLeft1->requestAction(WA_ACTIVATE);
    188187  wpRight2->requestAction(WA_ACTIVATE);
    189188  wpLeft2->requestAction(WA_ACTIVATE);
    190   //wpRight3->requestAction(WA_ACTIVATE);
    191   //wpLeft3->requestAction(WA_ACTIVATE);
     189  wpRight3->requestAction(WA_ACTIVATE);
     190  wpLeft3->requestAction(WA_ACTIVATE);
    192191
    193192  cannon->requestAction(WA_ACTIVATE);
     
    328327
    329328 
    330   this->trail = new Trail( 3, 3, .2, this);
     329  this->trail = new Trail( 10, 10, .2, this);
    331330  //this->trail->setParent( this);
    332331  this->trail->setTexture( "maps/engine.png");
    333332
    334   this->trailL = new Trail( 3, 3, .2, this);
     333  this->trailL = new Trail( 10, 10, .2, this);
    335334  //this->trailL->setParent( this);
    336335  this->trailL->setTexture( "maps/engine.png");
    337336
    338   this->trailR = new Trail( 3, 3, .2, this);
     337  this->trailR = new Trail( 10, 10, .2, this);
    339338  //this->trailR->setParent( this);
    340339  this->trailR->setTexture( "maps/engine.png");
     340
     341 
     342  this->toList(OM_GROUP_00);
    341343}
    342344
     
    374376  this->secWeaponMan.showCrosshair();
    375377  this->toList( OM_GROUP_01 );
     378  /*
    376379  for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    377380  {
    378381    if( likely( dynamic_cast<Weapon*>(*it) != NULL))
    379       dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00_PROJ);
    380   }
     382      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01);
     383  }*/
    381384  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    382385  //this->attachCamera();
     
    388391  this->secWeaponMan.hideCrosshair();
    389392  this->toList( OM_GROUP_00);
     393  /*
    390394  for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    391395  {
    392396    if( likely( dynamic_cast<Weapon*>(*it) != NULL))
    393       dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01_PROJ);
    394   }
     397      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);
     398  }*/
    395399  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    396400  //this->detachCamera();
     
    593597  explosionParticles->setRadius(.5, 6.0);
    594598  explosionParticles->setRadius(1.0, 3.0);
    595   explosionParticles->setColor(0.0, 1,1,0,.9);
    596   explosionParticles->setColor(0.5, .8,.8,0,.5);
    597   explosionParticles->setColor(1.0, .8,.8,.7,.0);
    598 
    599  
    600   emitter = new DotEmitter( 200, 0, 0);
    601   emitter->setSpread( M_PI, M_PI);
    602   emitter->setSpread( 50);
    603   emitter->setEmissionRate( 50.0);
    604   emitter->setEmissionVelocity( 150.0);
     599  explosionParticles->setColor(0.0, 1,1,1,.9);
     600  explosionParticles->setColor(0.1,  1,1,0,.9);
     601  explosionParticles->setColor(0.5, .8,.4,0,.5);
     602  explosionParticles->setColor(1.0, .2,.2,.2,.0);
     603
     604 
     605  emitter = new DotEmitter( 200, 200, M_2_PI);
     606  emitter->setSpread( 0, M_2_PI);
     607  emitter->setEmissionRate( 400.0);
     608  //emitter->setEmissionVelocity( 200.0);
    605609  emitter->setSystem( explosionParticles);
    606610  emitter->setAbsCoor( this->getAbsCoor());
     
    618622*/
    619623  this->setAbsCoor(Vector(-10000,10000,10000));
    620   this->hide();
     624  //this->hide();
    621625
    622626  this->toList( OM_DEAD);
    623   for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    624   {
    625     if( likely( dynamic_cast<Weapon*>(*it) != NULL))
    626       dynamic_cast<WorldEntity*>(*it)->toList( OM_DEAD);
    627   }
    628     PRINTF(0)("spaceship destroy == ship translated \n");
     627  PRINTF(0)("spaceship destroy == ship translated \n");
    629628}
    630629
    631630void SpaceShip::respawn( )
    632631{
    633   this->unhide();
     632  //this->unhide();
    634633  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    635634  {
     
    637636      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);
    638637  }*/
     638  /*
    639639  if( this->hasPlayer())
    640640  {
     
    654654                dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01_PROJ);
    655655        }
    656   }
     656  }*/
    657657
    658658}
     
    766766        this->travelNode->updateNode(0.01f);
    767767
    768         //this->setParent(this->travelNode);
     768        this->setParent(this->travelNode);
    769769        this->setRelCoor(0,0,0);
    770770
    771         //State::getCameraNode()->setParentSoft(this->travelNode);
    772         State::getCameraNode()->setParentSoft(this);
     771        State::getCameraNode()->setParentSoft(this->travelNode);
     772        //State::getCameraNode()->setParentSoft(this);
    773773        State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);
    774         //State::getCameraTargetNode()->setParentSoft(this->travelNode);
    775         State::getCameraTargetNode()->setParentSoft(this);
     774        State::getCameraTargetNode()->setParentSoft(this->travelNode);
     775        //State::getCameraTargetNode()->setParentSoft(this);
    776776        State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
    777777
     
    797797  float airCoeff = 2.5;
    798798  float pi = 3.14;
    799  
    800   Vector tempVelocity;
     799 
    801800
    802801  switch(this->getPlaymode())
     
    806805      // these routines will change the travel movement into zero in a short amout of time, if the player
    807806      // doesn't press any buttons.
    808       if (tempVelocity.x >= 0)
    809       {
    810         if (tempVelocity.x > airCoeff*this->acceleration * dt)
    811           tempVelocity.x -= airCoeff* this->acceleration * dt;
     807      if (this->travelVelocity.x >= 0)
     808      {
     809        if (this->travelVelocity.x > airCoeff*this->acceleration * dt)
     810          this->travelVelocity.x -= airCoeff* this->acceleration * dt;
    812811        else
    813           tempVelocity.x = 0;
     812          this->travelVelocity.x = 0;
    814813      }
    815814      else
    816815      {
    817         if (tempVelocity.x < -airCoeff*this->acceleration * dt)
    818           tempVelocity.x += airCoeff* this->acceleration * dt;
     816        if (this->travelVelocity.x < -airCoeff*this->acceleration * dt)
     817          this->travelVelocity.x += airCoeff* this->acceleration * dt;
    819818        else
    820           tempVelocity.x = 0;
    821       }
    822       if (tempVelocity.z >= 0)
    823       {
    824         if (tempVelocity.z > airCoeff*this->acceleration * dt)
    825           tempVelocity.z -= airCoeff* this->acceleration * dt;
     819          this->travelVelocity.x = 0;
     820      }
     821      if (this->travelVelocity.z >= 0)
     822      {
     823        if (this->travelVelocity.z > airCoeff*this->acceleration * dt)
     824          this->travelVelocity.z -= airCoeff* this->acceleration * dt;
    826825        else
    827           tempVelocity.z = 0;
     826          this->travelVelocity.z = 0;
    828827      }
    829828      else
    830829      {
    831         if (tempVelocity.z < -airCoeff*this->acceleration * dt)
    832           tempVelocity.z += airCoeff* this->acceleration * dt;
     830        if (this->travelVelocity.z < -airCoeff*this->acceleration * dt)
     831          this->travelVelocity.z += airCoeff* this->acceleration * dt;
    833832        else
    834           tempVelocity.z = 0;
     833          this->travelVelocity.z = 0;
    835834      }
    836835   
     
    850849        if(this->getRelCoor().x < this->travelDistancePlus.x)
    851850        {
    852           if (tempVelocity.x < this->travelSpeed)
     851          if (this->travelVelocity.x < this->travelSpeed)
    853852          {
    854             tempVelocity.x += (airCoeff + 1.0)*this->acceleration*dt;
     853            this->travelVelocity.x += (airCoeff + 1.0)*this->acceleration*dt;
    855854          }
    856855          else
    857856          {
    858             tempVelocity.x = this->travelSpeed;
     857            this->travelVelocity.x = this->travelSpeed;
    859858          }
    860859        }
    861860        else
    862861        {
    863           tempVelocity.x = 0.0f;
     862          this->travelVelocity.x = 0.0f;
    864863        }
    865864      }
     
    869868        if(this->getRelCoor().x > this->travelDistanceMinus.x)
    870869        {
    871           if (tempVelocity.x > -this->travelSpeed)
     870          if (this->travelVelocity.x > -this->travelSpeed)
    872871          {
    873             tempVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
     872            this->travelVelocity.x -= (airCoeff + 1.0)*this->acceleration*dt;
    874873          }
    875874          else
    876875          {
    877             tempVelocity.x = -this->travelSpeed;
     876            this->travelVelocity.x = -this->travelSpeed;
    878877          }
    879878        }
    880879        else
    881880        {
    882           tempVelocity.x = 0.0f;
     881          this->travelVelocity.x = 0.0f;
    883882        }
    884883      }
     
    888887        if(this->getRelCoor().z > this->travelDistanceMinus.y)
    889888        {
    890           if (tempVelocity.z > -this->travelSpeed)
     889          if (this->travelVelocity.z > -this->travelSpeed)
    891890          {
    892             tempVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
     891            this->travelVelocity.z -= (airCoeff + 1.0)*this->acceleration*dt;
    893892          }
    894893          else
    895894          {
    896             tempVelocity.z = -this->travelSpeed;
     895            this->travelVelocity.z = -this->travelSpeed;
    897896          }
    898897        }
    899898        else
    900899        {
    901           tempVelocity.z = 0.0f;
     900          this->travelVelocity.z = 0.0f;
    902901        }
    903902        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6);
     
    908907        if(this->getRelCoor().z < this->travelDistancePlus.y)
    909908        {
    910           if (tempVelocity.z < this->travelSpeed)
     909          if (this->travelVelocity.z < this->travelSpeed)
    911910          {
    912             tempVelocity.z += (airCoeff + 1.0)*this->acceleration*dt;
     911            this->travelVelocity.z += (airCoeff + 1.0)*this->acceleration*dt;
    913912          }
    914913          else
    915914          {
    916             tempVelocity.z = this->travelSpeed;
     915            this->travelVelocity.z = this->travelSpeed;
    917916          }
    918917        }
    919918        else
    920919        {
    921           tempVelocity.z = 0.0f;
     920          this->travelVelocity.z = 0.0f;
    922921        }
    923922        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6);
     
    930929
    931930      this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    932       this->shiftCoor (tempVelocity * dt);
     931      this->shiftCoor (this->travelVelocity * dt);
    933932
    934933    //normalisation of the vectors (vector sum must be <= travelspeed)
    935     float xzNorm = sqrt(pow(tempVelocity.x, 2) + pow(tempVelocity.z, 2));
     934    float xzNorm = sqrt(pow(this->travelVelocity.x, 2) + pow(this->travelVelocity.z, 2));
    936935    if (xzNorm > this->travelSpeed)
    937936    {
    938       tempVelocity.x = tempVelocity.x/xzNorm * this->travelSpeed;
    939       tempVelocity.z = tempVelocity.z/xzNorm * this->travelSpeed;
     937      this->travelVelocity.x = this->travelVelocity.x/xzNorm * this->travelSpeed;
     938      this->travelVelocity.z = this->travelVelocity.z/xzNorm * this->travelSpeed;
    940939    }
    941940
     
    944943   
    945944    //set new coordinates calculated through key- events.
    946     this->shiftCoor (tempVelocity * dt);
     945    this->shiftCoor (this->travelVelocity * dt);
    947946    break;
    948947    }
     
    956955/*
    957956  this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    958   this->shiftCoor (tempVelocity * dt);
    959 
    960   float angle = tempVelocity.z / travelSpeed * pi / 3;
     957  this->shiftCoor (this->travelVelocity * dt);
     958
     959  float angle = this->travelVelocity.z / travelSpeed * pi / 3;
    961960  if (angle > pi/4) angle = pi/4;
    962961  if (angle < -pi/4) angle = -pi/4;
Note: See TracChangeset for help on using the changeset viewer.