Changeset 6969 for code/branches/rocket2/src/modules/weapons
- Timestamp:
- May 27, 2010, 3:33:15 PM (15 years ago)
- Location:
- code/branches/rocket2/src/modules/weapons
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/rocket2/src/modules/weapons/RocketController.cc
r6966 r6969 80 80 void RocketController::setTargetPosition() 81 81 { 82 //this->targetPosition_=this->target_->getWorldPosition();83 this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity());82 this->targetPosition_=this->target_->getWorldPosition(); //don't really note a difference in the rocket behaviour xD 83 //this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getWorldPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getWorldPosition(), this->target_->getVelocity()); 84 84 } 85 85 void RocketController::moveToTargetPosition() -
code/branches/rocket2/src/modules/weapons/projectiles/Rocket.cc
r6540 r6969 87 87 this->defSndWpnEngine_->setLooping(true); 88 88 this->defSndWpnEngine_->setSource("sounds/Rocket_engine.ogg"); 89 this->defSndWpnEngine_->setVolume(100); 89 90 this->attach(defSndWpnEngine_); 90 91 … … 92 93 this->defSndWpnLaunch_->setLooping(false); 93 94 this->defSndWpnLaunch_->setSource("sounds/Rocket_launch.ogg"); 95 this->defSndWpnLaunch_->setVolume(100); 94 96 this->attach(defSndWpnLaunch_); 95 97 } -
code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc
r6966 r6969 58 58 this->localAngularVelocity_ = 0; 59 59 this->bDestroy_ = false; 60 this->lifetime_ = 1 00;60 this->lifetime_ = 120; 61 61 this->setMass(15); 62 62 COUT(4) << "simplerocket constructed\n"; 63 this->counter_=0; 64 this->slowing_=false; 63 this->maxLife_=90; 65 64 66 65 if (GameMode::isMaster()) … … 89 88 collisionShape->setHeight(200); 90 89 this->attachCollisionShape(collisionShape); 91 92 93 90 this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this))); 94 91 } … … 96 93 } 97 94 98 void SimpleRocket::disableFire(){ 99 this->setAcceleration(0,0,0); 100 this->setVelocity(Vector3(0,0,0)); 95 96 97 98 void SimpleRocket::tick(float dt) 99 { 100 101 SUPER(SimpleRocket, tick, dt); 102 if (this->getVelocity().squaredLength() >130000) this->maxLife_-=dt; //if Velocity bigger than about 360, uses a lot more "fuel" :) 101 103 102 this->fire_->detachFromParent();103 //this->fire_->setVisible(false);104 105 }106 107 108 void SimpleRocket::tick(float dt)109 {110 111 SUPER(SimpleRocket, tick, dt);112 counter_++;113 if (this->getVelocity().squaredLength() >130000 && !slowing_) counter_++; //if Velocity bigger than about 360, uses a lot more "fuel" :)114 104 115 105 this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_); … … 119 109 120 110 if (this->fuel_) { 121 COUT(0)<<this->getVelocity().length()<<endl; 122 if (this->counter_>1000 && counter_%12==0) 123 124 if (!this->slowing_) { 125 this->setAcceleration(this->getOrientation()*Vector3(10,10,10)); 126 this->slowing_=true; 127 } 128 129 if (this->counter_ > 1800) 111 if (this->destroyTimer_.getRemainingTime()< this->lifetime_-this->maxLife_ ) 130 112 this->fuel_=false; 131 } 113 } else this->disableFire(); 114 132 115 if( this->bDestroy_ ) 133 116 this->destroy(); 134 if (!this->fuel_) 135 this->disableFire(); 136 137 138 139 117 118 } 119 120 void SimpleRocket::disableFire(){ 121 this->setAcceleration(0,0,0); 122 this->fire_->detachFromParent(); 123 140 124 } 141 125 … … 221 205 } 222 206 223 void SimpleRocket::setDestroy()224 {225 this->bDestroy_=true;226 CCOUT(4)<<"trying to destroy";227 }228 207 229 208 void SimpleRocket::fired(unsigned int firemode) -
code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.h
r6966 r6969 131 131 bool bDestroy_; 132 132 bool fuel_; 133 bool slowing_;134 int counter_;135 133 136 134 … … 138 136 Timer destroyTimer_; 139 137 float lifetime_; 138 float maxLife_; 139 140 140 ParticleEmitter* fire_; 141 142 141 143 142 144
Note: See TracChangeset
for help on using the changeset viewer.