Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2006, 6:27:39 PM (18 years ago)
Author:
muellmic
Message:

updated accel / maxSpeed calculation, updated burst-emitter calculation

File:
1 edited

Legend:

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

    r10037 r10043  
    375375  this->travelDistancePlus = Vector2D(38.0, 43.0);
    376376  this->travelDistanceMinus = Vector2D(-38.0, -43.0);
    377   this->travelSpeed = 80;
    378377  this->cameraSpeed = 40;
    379378  this->cameraLook = 0.0f;
    380   this->acceleration = 120.0f;
    381379  //this->airFriction = 0.0f;
    382380
     
    404402{
    405403  //this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));
    406 }
    407 
    408 void SpaceShip::setTravelSpeed(float travelSpeed)
    409 {
    410   this->travelSpeed = travelSpeed;
    411404}
    412405
     
    533526  this->engineSpeedCur = this->engineSpeedBase + this->reactorOutput * this->engineEnergyShare;
    534527
     528  // calculation of maxSpeed and acceleration:
     529  this->travelSpeed = this->engineSpeedCur * 5;
     530  this->acceleration = this->travelSpeed * 2;
    535531
    536532  /*
     
    569565  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    570566
    571   this->burstEmitter->setEmissionRate(travelSpeed);
    572   this->burstEmitter->setEmissionVelocity(travelSpeed*.5, travelSpeed *.1);
     567  this->burstEmitter->setEmissionRate(this->cameraSpeed + (velocity.z>0)*velocity.z);
     568  this->burstEmitter->setEmissionVelocity(this->cameraSpeed + (velocity.z>0)*velocity.z, travelSpeed *.1);
    573569
    574570  //orient the spaceship in direction of the mouse
     
    833829  //the ship doesn't slide too much.
    834830  float airCoeff = 2.5;
    835 
    836831  float pi = 3.14;
    837 
    838832 
    839833
     
    883877      if( this->systemFailure() )
    884878        bForward = bBackward = bLeft = bRight = false;
    885    
    886879   
    887880      if( this->bForward )
     
    940933          this->velocity.z = 0.0f;
    941934        }
    942         this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 3);
     935        this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 6);
    943936      }
    944937   
     
    960953          this->velocity.z = 0.0f;
    961954        }
    962         this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 3);
     955        this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 6);
    963956      }
    964957      if (!this->bRight && !this->bLeft)
    965958      {
    966         this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 3);
    967       }
     959        this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 6);
     960      }
     961     
    968962
    969963      this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
    970964      this->shiftCoor (this->velocity * dt);
    971965
    972 
    973       break;
     966    //normalisation of the vectors (vector sum must be <= travelspeed)
     967    float xzNorm = sqrt(pow(this->velocity.x, 2) + pow(this->velocity.z, 2));
     968    if (xzNorm > this->travelSpeed)
     969    {
     970      this->velocity.x = this->velocity.x/xzNorm * this->travelSpeed;
     971      this->velocity.z = this->velocity.z/xzNorm * this->travelSpeed;
     972    }
     973
     974    //this moves camera and ship along the travel path.
     975    this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));
     976   
     977    //set new coordinates calculated through key- events.
     978    this->shiftCoor (this->velocity * dt);
     979    break;
    974980    }
    975981    case Playable::Vertical:
    976     {
    977982      break;
    978     }
    979983    default:
    980984      PRINTF(4)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName());
Note: See TracChangeset for help on using the changeset viewer.