Changeset 3646 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Mar 23, 2005, 5:43:07 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/projectile.cc
r3633 r3646 20 20 21 21 #include "world_entity.h" 22 #include "null_parent.h" 22 23 #include "objModel.h" 23 24 #include "primitive.h" … … 35 36 this->projectileModel = new Primitive(P_SPHERE); 36 37 this->flightDirection = NULL; 38 this->currentLifeTime = 0.0f; 39 this->ttl = 1.0f; 37 40 this->speed = 1.1f; 38 41 } … … 69 72 70 73 /** 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 */ 79 void Projectile::setTTL(float ttl) 80 { 81 this->ttl = ttl; 82 } 83 84 85 /** 71 86 \brief signal tick, time dependent things will be handled here 72 87 \param time since last tick … … 74 89 void Projectile::tick (float time) 75 90 { 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 78 102 } 79 103 -
orxonox/trunk/src/world_entities/projectile.h
r3632 r3646 21 21 22 22 void setFlightDirection(Quaternion* flightDirection); 23 void setSpeed(float speed); 24 void setTTL(float ttl); 23 25 24 26 virtual void hit (WorldEntity* weapon, Vector* loc); … … 32 34 Primitive* projectileModel; //!< this serves temporary as a plasma bullet 33 35 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 34 38 Vector* flightDirection; //!< direction in which the shoot flights 39 35 40 }; 36 41 -
orxonox/trunk/src/world_entities/test_gun.cc
r3632 r3646 93 93 pj->setFlightDirection(q); 94 94 95 printf("TestGun::current speed is: %f", this->getSpeed()); 96 95 97 this->worldEntities->add(pj); 96 98 } -
orxonox/trunk/src/world_entities/weapon.cc
r3631 r3646 183 183 */ 184 184 void Weapon::fire() 185 { 186 187 } 185 {} 188 186 189 187 -
orxonox/trunk/src/world_entities/weapon.h
r3631 r3646 61 61 bool hasWeaponIdleTimeElapsed(void); 62 62 63 virtual void fire(void) ;63 virtual void fire(void) = 0; 64 64 virtual void hit (WorldEntity* weapon, Vector* loc); 65 65 virtual void destroy(void);
Note: See TracChangeset
for help on using the changeset viewer.