- Timestamp:
- May 27, 2010, 3:33:15 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.