Changeset 5456 in orxonox.OLD for trunk/src/world_entities/weapons/rocket.cc
- Timestamp:
- Oct 30, 2005, 12:54:23 AM (20 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
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);
Note: See TracChangeset
for help on using the changeset viewer.