Changeset 3683 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Mar 30, 2005, 9:37:52 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/player.cc
r3675 r3683 52 52 acceleration = 10.0; 53 53 //weapons: 54 Weapon* wp = new TestGun(this, new Vector(), new Quaternion );54 Weapon* wp = new TestGun(this, new Vector(), new Quaternion()); 55 55 this->weapons->add(wp); 56 56 this->activeWeapon = wp; -
orxonox/trunk/src/world_entities/projectile.cc
r3678 r3683 20 20 21 21 #include "world_entity.h" 22 #include "weapon.h" 22 23 #include "null_parent.h" 23 24 #include "model.h" … … 30 31 \brief standard constructor 31 32 */ 32 Projectile::Projectile ( ) : WorldEntity()33 Projectile::Projectile (Weapon* weapon) : WorldEntity() 33 34 { 34 35 this->model = (Model*)ResourceManager::getInstance()->load("sphere", PRIM, RP_LEVEL); 36 this->weapon = weapon; 35 37 this->flightDirection = NULL; 36 38 this->currentLifeTime = 0.0f; … … 66 68 Vector v(1, 0, 0); 67 69 *this->flightDirection = flightDirection->apply(v); 70 this->flightDirection->normalize(); 68 71 } 69 72 … … 86 89 void Projectile::setSpeed(float speed) 87 90 { 88 this->speed = speed ;91 this->speed = speed * 5; 89 92 printf("Projectile::setting speed to: %f\n", this->speed); 90 93 } … … 96 99 void Projectile::tick (float time) 97 100 { 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 98 105 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(); 110 108 } 111 109 -
orxonox/trunk/src/world_entities/projectile.h
r3676 r3683 10 10 11 11 class Vector; 12 class Weapon; 12 13 13 14 class Projectile : public WorldEntity … … 16 17 17 18 public: 18 Projectile ( );19 Projectile (Weapon* weapon); 19 20 virtual ~Projectile (); 20 21 … … 35 36 float ttl; //!< time to life, after this time, the projectile will garbage collect itself 36 37 Vector* flightDirection; //!< direction in which the shoot flights 38 Weapon* weapon; //!< weapon the shoot belongs to 37 39 38 40 }; -
orxonox/trunk/src/world_entities/test_gun.cc
r3677 r3683 41 41 TestGun::TestGun (PNode* parent, Vector* coordinate, Quaternion* direction) 42 42 : Weapon (parent, coordinate, direction) 43 {} 43 { 44 } 44 45 45 46 … … 83 84 { 84 85 //printf("TestGun::fire() - firing weapon now ---------------------------\n"); 85 Projectile* pj = new Projectile( );86 Projectile* pj = new Projectile(this); 86 87 87 88 Vector* v = new Vector(); … … 93 94 94 95 pj->setFlightDirection(q); 95 //pj->setSpeed(this->getSpeed() * 0.025);96 pj->setSpeed(this->getSpeed()); 96 97 97 98
Note: See TracChangeset
for help on using the changeset viewer.