Changeset 4890 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons/projectile.cc
- Timestamp:
- Jul 19, 2005, 12:20:58 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/projectile.cc
r4836 r4890 36 36 37 37 this->weapon = weapon; 38 this->flightDirection = NULL; 39 this->currentLifeTime = 0.0f; 40 this->ttl = 0.75f; /* sec */ 41 this->speed = 2.0f; 38 this->lifeCycle = 0.0; 39 this->lifeSpan = 0.75f; /* sec */ 42 40 } 43 41 … … 65 63 void Projectile::setFlightDirection(Quaternion flightDirection) 66 64 { 67 if( this->flightDirection == NULL)68 this->flightDirection = new Vector();69 65 Vector v(1, 0, 0); 70 *this->flightDirection = flightDirection.apply(v);71 this->flightDirection ->normalize();66 this->flightDirection = flightDirection.apply(v); 67 this->flightDirection.normalize(); 72 68 } 73 74 75 /**76 * this sets the time to life of the projectile77 * @param ttl in second78 79 after this life time, the projectile will garbage collect itself80 */81 void Projectile::setTTL(float ttl)82 {83 this->ttl = ttl;84 }85 86 87 /**88 * sets the speed of the projectile89 */90 void Projectile::setSpeed(float speed)91 {92 this->speed = speed * 3; /* fix speed settings */93 PRINTF(4)("Projectile::setting speed to: %f\n", this->speed);94 }95 96 69 97 70 /** … … 101 74 void Projectile::setVelocity(const Vector &velocity) 102 75 { 103 this->offsetVel = this->velocity = velocity;104 this->offsetVel.normalize();105 this->velocity += ( this->offsetVel * 50.0);76 Vector offsetVel = this->velocity = velocity; 77 offsetVel.normalize(); 78 this->velocity += (offsetVel * 50.0); 106 79 } 107 80 … … 116 89 this->shiftCoor(v); 117 90 118 this->currentLifeTime += time; 119 if( this->ttl < this->currentLifeTime) 120 { 121 PRINTF(5)("FINALIZE==========================\n"); 122 PRINTF(5)("current life time is: %f/%f\n", this->currentLifeTime, this->ttl); 123 PRINTF(5)("FINALIZE===========================\n"); 124 this->finalize(); 125 this->currentLifeTime = 0.0f; 126 } 91 this->lifeCycle += time/this->lifeSpan; 92 if( this->lifeCycle >= 1) 93 { 94 PRINTF(5)("FINALIZE==========================\n"); 95 PRINTF(5)("current life cycle is: %f\n", this->lifeCycle); 96 PRINTF(5)("FINALIZE===========================\n"); 97 this->finalize(); 98 } 127 99 } 128 129 /**130 * the projectile gets hit by another entity131 * @param the other entity132 * @param place where it is hit133 */134 void Projectile::hit (WorldEntity* entity, Vector* place)135 {}136 100 137 101
Note: See TracChangeset
for help on using the changeset viewer.