Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 19, 2005, 12:20:58 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: remake of the Projectile and TestBullet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/world_entities/weapons/projectile.cc

    r4836 r4890  
    3636
    3737  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 */
    4240}
    4341
     
    6563void Projectile::setFlightDirection(Quaternion flightDirection)
    6664{
    67   if( this->flightDirection == NULL)
    68     this->flightDirection = new Vector();
    6965  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();
    7268}
    73 
    74 
    75 /**
    76  *  this sets the time to life of the projectile
    77  * @param ttl in second
    78 
    79    after this life time, the projectile will garbage collect itself
    80 */
    81 void Projectile::setTTL(float ttl)
    82 {
    83   this->ttl = ttl;
    84 }
    85 
    86 
    87 /**
    88  *  sets the speed of the projectile
    89 */
    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 
    9669
    9770/**
     
    10174void Projectile::setVelocity(const Vector &velocity)
    10275{
    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);
    10679}
    10780
     
    11689  this->shiftCoor(v);
    11790
    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  }
    12799}
    128 
    129 /**
    130  *  the projectile gets hit by another entity
    131  * @param the other entity
    132  * @param place where it is hit
    133 */
    134 void Projectile::hit (WorldEntity* entity, Vector* place)
    135 {}
    136100
    137101
Note: See TracChangeset for help on using the changeset viewer.