Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 30, 2005, 9:37:52 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: projectile speed issue: fixed some strange behaveour. still got the problem, that the the projectile have variable relative speeds to the player…

File:
1 edited

Legend:

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

    r3678 r3683  
    2020
    2121#include "world_entity.h"
     22#include "weapon.h"
    2223#include "null_parent.h"
    2324#include "model.h"
     
    3031   \brief standard constructor
    3132*/
    32 Projectile::Projectile () : WorldEntity()
     33Projectile::Projectile (Weapon* weapon) : WorldEntity()
    3334{
    3435  this->model = (Model*)ResourceManager::getInstance()->load("sphere", PRIM, RP_LEVEL);
     36  this->weapon = weapon;
    3537  this->flightDirection = NULL;
    3638  this->currentLifeTime = 0.0f;
     
    6668  Vector v(1, 0, 0);
    6769  *this->flightDirection = flightDirection->apply(v);
     70  this->flightDirection->normalize();
    6871}
    6972
     
    8689void Projectile::setSpeed(float speed)
    8790{
    88   this->speed = speed;
     91  this->speed = speed * 5;
    8992  printf("Projectile::setting speed to: %f\n", this->speed);
    9093}
     
    9699void Projectile::tick (float time)
    97100{
     101  this->speed = this->weapon->getSpeed() * 5; 
     102  this->shiftCoor(*this->flightDirection * this->speed * time);
     103  printf("current speed is: %f\n", this->speed);
     104
    98105  this->currentLifeTime += time;
    99   if( this->ttl < this->currentLifeTime)
    100     {
    101       *this->flightDirection = *this->flightDirection * this->speed * time;
    102       this->shiftCoor(this->flightDirection);
    103       this->flightDirection->debug();
    104       return;
    105     }
    106   this->finalize();
    107   //NullParent* np = NullParent::getInstance();
    108   /* garbage colelction */
    109   // \fix: there is no gc in this class, its all been done by GarbageCollector
     106  if( this->ttl > this->currentLifeTime)
     107    this->finalize();
    110108}
    111109
Note: See TracChangeset for help on using the changeset viewer.