Changeset 5456 in orxonox.OLD for trunk/src/world_entities/weapons
- Timestamp:
- Oct 30, 2005, 12:54:23 AM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 2 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/laser.cc
r5451 r5456 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 17 17 18 #include " test_bullet.h"18 #include "laser.h" 19 19 20 20 #include "fast_factory.h" … … 31 31 using namespace std; 32 32 33 CREATE_FAST_FACTORY_STATIC( TestBullet, CL_TEST_BULLET);33 CREATE_FAST_FACTORY_STATIC(Laser, CL_LASER); 34 34 35 35 /** 36 36 * standard constructor 37 37 */ 38 TestBullet::TestBullet() : Projectile()38 Laser::Laser () : Projectile() 39 39 { 40 this->setClassID(CL_TEST_BULLET, " TestBullet");40 this->setClassID(CL_TEST_BULLET, "Laser"); 41 41 42 42 float modelSize = .3; 43 this->loadModelWithScale("models/projectiles/ orx-rocket.obj", .3);43 this->loadModelWithScale("models/projectiles/lasers.obj", .3); 44 44 45 45 this->energyMin = 1; … … 51 51 this->emitter->setParent(this); 52 52 this->emitter->setSpread(M_PI, M_PI); 53 this->emitter->setEmissionRate(30.0); 54 this->emitter->setEmissionVelocity(50.0); 53 55 } 54 56 … … 57 59 * standard deconstructor 58 60 */ 59 TestBullet::~TestBullet()61 Laser::~Laser () 60 62 { 61 63 // delete this->emitter; 62 64 63 65 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if ( TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)66 if (Laser::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 65 67 { 66 if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM)) 67 delete TestBullet::trailParticles; 68 TestBullet::trailParticles = NULL; 69 } 70 if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 71 { 72 if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM)) 73 delete TestBullet::explosionParticles; 74 TestBullet::explosionParticles = NULL; 68 if (ClassList::exists(Laser::explosionParticles, CL_PARTICLE_SYSTEM)) 69 delete Laser::explosionParticles; 70 Laser::explosionParticles = NULL; 75 71 } 76 72 77 73 } 78 74 79 ParticleSystem* TestBullet::trailParticles = NULL; 80 ParticleSystem* TestBullet::explosionParticles = NULL; 75 ParticleSystem* Laser::explosionParticles = NULL; 81 76 82 void TestBullet::activate()77 void Laser::activate() 83 78 { 84 79 State::getWorldEntityList()->add(this); 85 if (unlikely( TestBullet::trailParticles == NULL))80 if (unlikely(Laser::explosionParticles == NULL)) 86 81 { 87 TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE);88 TestBullet::trailParticles->setName("TestBulletTrailParticles");89 TestBullet::trailParticles->setLifeSpan(.5, .3);90 TestBullet::trailParticles->setRadius(0.0, .5);91 TestBullet::trailParticles->setRadius(0.5, 2.0);92 TestBullet::trailParticles->setRadius(1.0, 5.0);93 TestBullet::trailParticles->setColor(0.0, 1,0,0,.7);94 TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5);95 TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0);82 Laser::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 83 Laser::explosionParticles->setName("LaserExplosionParticles"); 84 Laser::explosionParticles->setLifeSpan(.5, .3); 85 Laser::explosionParticles->setRadius(0.0, 10); 86 Laser::explosionParticles->setRadius(.5, 20.0); 87 Laser::explosionParticles->setRadius(1.0, 3.0); 88 Laser::explosionParticles->setColor(0.0, 0,1,0,.9); 89 Laser::explosionParticles->setColor(0.5, .8,.8,0,.5); 90 Laser::explosionParticles->setColor(1.0, 1,1,1,.0); 96 91 } 97 if (unlikely(TestBullet::explosionParticles == NULL))98 {99 TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);100 TestBullet::explosionParticles->setName("TestBulletExplosionParticles");101 TestBullet::explosionParticles->setLifeSpan(.5, .3);102 TestBullet::explosionParticles->setRadius(0.0, 10);103 TestBullet::explosionParticles->setRadius(.5, 20.0);104 TestBullet::explosionParticles->setRadius(1.0, 3.0);105 TestBullet::explosionParticles->setColor(0.0, 0,1,0,.9);106 TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);107 TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0);108 }109 110 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles);111 112 this->emitter->setEmissionRate(20.0);113 this->emitter->setEmissionVelocity(3.0);114 92 } 115 93 116 94 117 void TestBullet::deactivate()95 void Laser::deactivate() 118 96 { 119 97 ParticleEngine::getInstance()->breakConnections(this->emitter); … … 122 100 // GarbageCollector::getInstance()->collect(this); 123 101 State::getWorldEntityList()->remove(this); 124 TestBullet::fastFactory->kill(this);102 Laser::fastFactory->kill(this); 125 103 } 126 104 127 105 128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)106 void Laser::collidesWith(WorldEntity* entity, const Vector& location) 129 107 { 130 108 if (this->hitEntity != entity && entity->isA(CL_NPC)) … … 137 115 * @param time since last tick 138 116 */ 139 void TestBullet::tick (float time)117 void Laser::tick (float time) 140 118 { 141 119 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); … … 157 135 * the function gets called, when the projectile is destroyed 158 136 */ 159 void TestBullet::destroy ()137 void Laser::destroy () 160 138 { 161 PRINTF(5)("DESTROY TestBullet\n");139 PRINTF(5)("DESTROY Laser\n"); 162 140 this->lifeCycle = .95; //!< @todo calculate this usefully. 163 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles); 164 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 165 166 this->emitter->setEmissionRate(30.0); 167 this->emitter->setEmissionVelocity(50.0); 168 // this->deactivate(); 141 ParticleEngine::getInstance()->addConnection(this->emitter, Laser::explosionParticles); 169 142 170 143 } 171 144 172 145 173 void TestBullet::draw ()146 void Laser::draw () 174 147 { 175 148 glMatrixMode(GL_MODELVIEW); -
trunk/src/world_entities/weapons/laser.h
r5449 r5456 1 1 /*! 2 \projectile.h3 *a projectile, that is been shooted by a weapon2 * @file laser.h 3 * @brief a projectile, that is been shooted by a weapon 4 4 */ 5 5 6 #ifndef _ TEST_BULLET_H7 #define _ TEST_BULLET_H6 #ifndef _LASER_H 7 #define _LASER_H 8 8 9 9 #include "projectile.h" … … 15 15 class FastFactory; 16 16 17 class TestBullet: public Projectile17 class Laser : public Projectile 18 18 { 19 19 public: 20 TestBullet();21 virtual ~ TestBullet();20 Laser (); 21 virtual ~Laser (); 22 22 23 23 … … 35 35 private: 36 36 static FastFactory* fastFactory; 37 static ParticleSystem* trailParticles; 37 38 38 static ParticleSystem* explosionParticles; 39 39 … … 45 45 }; 46 46 47 #endif /* _ TEST_BULLET_H */47 #endif /* _LASER_H */ -
trunk/src/world_entities/weapons/rocket.cc
r5451 r5456 16 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON 17 17 18 #include " test_bullet.h"18 #include "rocket.h" 19 19 20 20 #include "fast_factory.h" … … 31 31 using namespace std; 32 32 33 CREATE_FAST_FACTORY_STATIC( TestBullet, CL_TEST_BULLET);33 CREATE_FAST_FACTORY_STATIC(Rocket, CL_ROCKET); 34 34 35 35 /** 36 36 * standard constructor 37 37 */ 38 TestBullet::TestBullet () : Projectile()38 Rocket::Rocket () : Projectile() 39 39 { 40 this->setClassID(CL_TEST_BULLET, " TestBullet");40 this->setClassID(CL_TEST_BULLET, "Rocket"); 41 41 42 42 float modelSize = .3; … … 57 57 * standard deconstructor 58 58 */ 59 TestBullet::~TestBullet ()59 Rocket::~Rocket () 60 60 { 61 61 // delete this->emitter; 62 62 63 63 /* this is normaly done by World.cc by deleting the ParticleEngine */ 64 if ( TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)64 if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 65 65 { 66 if (ClassList::exists( TestBullet::trailParticles, CL_PARTICLE_SYSTEM))67 delete TestBullet::trailParticles;68 TestBullet::trailParticles = NULL;66 if (ClassList::exists(Rocket::trailParticles, CL_PARTICLE_SYSTEM)) 67 delete Rocket::trailParticles; 68 Rocket::trailParticles = NULL; 69 69 } 70 if ( TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)70 if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1) 71 71 { 72 if (ClassList::exists( TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))73 delete TestBullet::explosionParticles;74 TestBullet::explosionParticles = NULL;72 if (ClassList::exists(Rocket::explosionParticles, CL_PARTICLE_SYSTEM)) 73 delete Rocket::explosionParticles; 74 Rocket::explosionParticles = NULL; 75 75 } 76 76 77 77 } 78 78 79 ParticleSystem* TestBullet::trailParticles = NULL;80 ParticleSystem* TestBullet::explosionParticles = NULL;79 ParticleSystem* Rocket::trailParticles = NULL; 80 ParticleSystem* Rocket::explosionParticles = NULL; 81 81 82 void TestBullet::activate()82 void Rocket::activate() 83 83 { 84 84 State::getWorldEntityList()->add(this); 85 if (unlikely( TestBullet::trailParticles == NULL))85 if (unlikely(Rocket::trailParticles == NULL)) 86 86 { 87 TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE);88 TestBullet::trailParticles->setName("TestBulletTrailParticles");89 TestBullet::trailParticles->setLifeSpan(.5, .3);90 TestBullet::trailParticles->setRadius(0.0, .5);91 TestBullet::trailParticles->setRadius(0.5, 2.0);92 TestBullet::trailParticles->setRadius(1.0, 5.0);93 TestBullet::trailParticles->setColor(0.0, 1,0,0,.7);94 TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5);95 TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0);87 Rocket::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 88 Rocket::trailParticles->setName("RocketTrailParticles"); 89 Rocket::trailParticles->setLifeSpan(.5, .3); 90 Rocket::trailParticles->setRadius(0.0, .5); 91 Rocket::trailParticles->setRadius(0.5, 2.0); 92 Rocket::trailParticles->setRadius(1.0, 5.0); 93 Rocket::trailParticles->setColor(0.0, 1,0,0,.7); 94 Rocket::trailParticles->setColor(0.5, .8,.8,0,.5); 95 Rocket::trailParticles->setColor(1.0, .7,.7,.7,.0); 96 96 } 97 if (unlikely( TestBullet::explosionParticles == NULL))97 if (unlikely(Rocket::explosionParticles == NULL)) 98 98 { 99 TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);100 TestBullet::explosionParticles->setName("TestBulletExplosionParticles");101 TestBullet::explosionParticles->setLifeSpan(.5, .3);102 TestBullet::explosionParticles->setRadius(0.0, 10);103 TestBullet::explosionParticles->setRadius(.5, 20.0);104 TestBullet::explosionParticles->setRadius(1.0, 3.0);105 TestBullet::explosionParticles->setColor(0.0, 0,1,0,.9);106 TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);107 TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0);99 Rocket::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE); 100 Rocket::explosionParticles->setName("RocketExplosionParticles"); 101 Rocket::explosionParticles->setLifeSpan(.5, .3); 102 Rocket::explosionParticles->setRadius(0.0, 10); 103 Rocket::explosionParticles->setRadius(.5, 20.0); 104 Rocket::explosionParticles->setRadius(1.0, 3.0); 105 Rocket::explosionParticles->setColor(0.0, 0,1,0,.9); 106 Rocket::explosionParticles->setColor(0.5, .8,.8,0,.5); 107 Rocket::explosionParticles->setColor(1.0, 1,1,1,.0); 108 108 } 109 109 110 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles);110 ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::trailParticles); 111 111 112 112 this->emitter->setEmissionRate(20.0); … … 115 115 116 116 117 void TestBullet::deactivate()117 void Rocket::deactivate() 118 118 { 119 119 ParticleEngine::getInstance()->breakConnections(this->emitter); … … 122 122 // GarbageCollector::getInstance()->collect(this); 123 123 State::getWorldEntityList()->remove(this); 124 TestBullet::fastFactory->kill(this);124 Rocket::fastFactory->kill(this); 125 125 } 126 126 127 127 128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)128 void Rocket::collidesWith(WorldEntity* entity, const Vector& location) 129 129 { 130 130 if (this->hitEntity != entity && entity->isA(CL_NPC)) … … 137 137 * @param time since last tick 138 138 */ 139 void TestBullet::tick (float time)139 void Rocket::tick (float time) 140 140 { 141 141 //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1); … … 157 157 * the function gets called, when the projectile is destroyed 158 158 */ 159 void TestBullet::destroy ()159 void Rocket::destroy () 160 160 { 161 PRINTF(5)("DESTROY TestBullet\n");161 PRINTF(5)("DESTROY Rocket\n"); 162 162 this->lifeCycle = .95; //!< @todo calculate this usefully. 163 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles);164 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles);163 ParticleEngine::getInstance()->breakConnection(this->emitter, Rocket::trailParticles); 164 ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::explosionParticles); 165 165 166 166 this->emitter->setEmissionRate(30.0); … … 171 171 172 172 173 void TestBullet::draw ()173 void Rocket::draw () 174 174 { 175 175 glMatrixMode(GL_MODELVIEW); -
trunk/src/world_entities/weapons/rocket.h
r5449 r5456 1 1 /*! 2 \projectile.h3 * a projectile, that is been shooted by a weapon2 * @file rocket.h 3 * @brief a Rocket Projectile 4 4 */ 5 5 6 #ifndef _ TEST_BULLET_H7 #define _ TEST_BULLET_H6 #ifndef _ROCKET_H 7 #define _ROCKET_H 8 8 9 9 #include "projectile.h" … … 15 15 class FastFactory; 16 16 17 class TestBullet : public Projectile17 class Rocket : public Projectile 18 18 { 19 19 public: 20 TestBullet ();21 virtual ~ TestBullet ();20 Rocket (); 21 virtual ~Rocket (); 22 22 23 23 … … 45 45 }; 46 46 47 #endif /* _ TEST_BULLET_H */47 #endif /* _ROCKET_H */ -
trunk/src/world_entities/weapons/test_gun.cc
r5443 r5456 134 134 135 135 this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); 136 this->setProjectileType(CL_ TEST_BULLET);136 this->setProjectileType(CL_LASER); 137 137 this->prepareProjectiles(20); 138 138 } -
trunk/src/world_entities/weapons/turret.cc
r5443 r5456 92 92 93 93 this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET); 94 this->setProjectileType(CL_ TEST_BULLET);94 this->setProjectileType(CL_ROCKET); 95 95 96 96
Note: See TracChangeset
for help on using the changeset viewer.