Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3646 in orxonox.OLD for orxonox/trunk/src/world_entities


Ignore:
Timestamp:
Mar 23, 2005, 5:43:07 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: implemented garbage collector, is not yet collecting, i have to update the list.h first.

Location:
orxonox/trunk/src/world_entities
Files:
5 edited

Legend:

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

    r3633 r3646  
    2020
    2121#include "world_entity.h"
     22#include "null_parent.h"
    2223#include "objModel.h"
    2324#include "primitive.h"
     
    3536  this->projectileModel = new Primitive(P_SPHERE);
    3637  this->flightDirection = NULL;
     38  this->currentLifeTime = 0.0f;
     39  this->ttl = 1.0f;
    3740  this->speed = 1.1f;
    3841}
     
    6972
    7073/**
     74   \brief this sets the time to life of the projectile
     75   \param ttl in second
     76
     77   after this life time, the projectile will garbage collect itself
     78*/
     79void Projectile::setTTL(float ttl)
     80{
     81  this->ttl = ttl;
     82}
     83
     84
     85/**
    7186   \brief signal tick, time dependent things will be handled here
    7287   \param time since last tick
     
    7489void Projectile::tick (float time)
    7590{
    76   *this->flightDirection = *this->flightDirection * speed;
    77   this->shiftCoor(this->flightDirection);
     91  this->currentLifeTime += time;
     92  if( this->ttl < this->currentLifeTime)
     93    {
     94      *this->flightDirection = *this->flightDirection * speed;
     95      this->shiftCoor(this->flightDirection);
     96      return;
     97    }
     98  this->finalize();
     99  //NullParent* np = NullParent::getInstance();
     100  /* garbage colelction */
     101  // \fix: there is no gc in this class, its all been done by GarbageCollector
    78102}
    79103
  • orxonox/trunk/src/world_entities/projectile.h

    r3632 r3646  
    2121
    2222  void setFlightDirection(Quaternion* flightDirection);
     23  void setSpeed(float speed);
     24  void setTTL(float ttl);
    2325
    2426  virtual void hit (WorldEntity* weapon, Vector* loc);
     
    3234  Primitive* projectileModel;          //!< this serves temporary as a plasma bullet
    3335  float speed;                         //!< this is the speed of the projectile
     36  float currentLifeTime;               //!< this is the time, the projectile exists in this world (incremented by tick)
     37  float ttl;                           //!< time to life, after this time, the projectile will garbage collect itself
    3438  Vector* flightDirection;             //!< direction in which the shoot flights
     39 
    3540};
    3641
  • orxonox/trunk/src/world_entities/test_gun.cc

    r3632 r3646  
    9393  pj->setFlightDirection(q);
    9494
     95  printf("TestGun::current speed is: %f", this->getSpeed());
     96
    9597  this->worldEntities->add(pj);
    9698}
  • orxonox/trunk/src/world_entities/weapon.cc

    r3631 r3646  
    183183*/
    184184void Weapon::fire()
    185 {
    186  
    187 }
     185{}
    188186
    189187
  • orxonox/trunk/src/world_entities/weapon.h

    r3631 r3646  
    6161  bool hasWeaponIdleTimeElapsed(void);
    6262
    63   virtual void fire(void);
     63  virtual void fire(void) = 0;
    6464  virtual void hit (WorldEntity* weapon, Vector* loc);
    6565  virtual void destroy(void);
Note: See TracChangeset for help on using the changeset viewer.