Changeset 5443 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Oct 28, 2005, 9:44:57 PM (19 years ago)
- Location:
- trunk/src/world_entities/weapons
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/weapons/projectile.h
r5039 r5443 44 44 45 45 46 /** @brief This is called, when the Projectile is Emitted */ 47 virtual void activate() = 0; 48 /** @brief This is called, when the Projectile is being destroyed, or deleted */ 49 virtual void deactivate() = 0; 46 50 47 51 virtual void destroy (); -
trunk/src/world_entities/weapons/test_bullet.cc
r5357 r5443 1 2 3 1 /* 4 2 orxonox - the future of 3D-vertical-scrollers … … 13 11 ### File Specific 14 12 main-programmer: Patrick Boenzli 15 co-programmer: 13 co-programmer: Benjamin Grauer 14 16 15 */ 17 16 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON … … 24 23 #include "fast_factory.h" 25 24 26 #include "obb_tree.h" 25 #include "state.h" 26 #include "list.h" 27 28 #include "particle_engine.h" 29 #include "particle_emitter.h" 30 #include "particle_system.h" 31 27 32 28 33 using namespace std; … … 44 49 this->remove(); 45 50 this->lifeSpan = 5; 51 52 this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 0.01); 53 this->emitter->setParent(this); 54 this->emitter->setEmissionRate(20); 55 56 this->emitter->setSpread(M_2_PI); 46 57 } 47 58 … … 52 63 TestBullet::~TestBullet () 53 64 { 65 delete this->emitter; 54 66 /* 55 67 do not delete the test projectModel, since it is pnode … … 59 71 } 60 72 73 ParticleSystem* TestBullet::explosionParticles = NULL; 74 75 76 void TestBullet::activate() 77 { 78 State::getWorldEntityList()->add(this); 79 if (unlikely(TestBullet::explosionParticles == NULL)) 80 { 81 TestBullet::explosionParticles = new ParticleSystem(10000, PARTICLE_SPRITE); 82 TestBullet::explosionParticles->setLifeSpan(.5); 83 TestBullet::explosionParticles->setRadius(0.0, .5); 84 TestBullet::explosionParticles->setRadius(0.5, 2.0); 85 TestBullet::explosionParticles->setRadius(0.0, 0.0); 86 TestBullet::explosionParticles->setColor(0.0, 1,0,0,.7); 87 TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5); 88 TestBullet::explosionParticles->setColor(1.0, .5,.5,.5,.0); 89 } 90 91 ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles); 92 } 93 94 95 void TestBullet::deactivate() 96 { 97 ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::explosionParticles); 98 99 GarbageCollector::getInstance()->collect(this); 100 this->lifeCycle = 0.0; 101 } 102 103 61 104 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location) 62 105 { 63 this->destroy(); 106 64 107 } 65 108 … … 81 124 PRINTF(5)("FINALIZE===========================\n"); 82 125 // this->finalize(); 83 GarbageCollector::getInstance()->collect(this); 84 this->lifeCycle = 0.0; //! @todo should not be here 126 this->deactivate(); 85 127 } 86 128 } … … 91 133 void TestBullet::destroy () 92 134 { 135 this->deactivate(); 93 136 137 138 GarbageCollector::getInstance()->collect(this); 94 139 95 140 } -
trunk/src/world_entities/weapons/test_bullet.h
r5257 r5443 11 11 class Vector; 12 12 class Weapon; 13 class ParticleSystem; 14 class ParticleEmitter; 13 15 14 16 class TestBullet : public Projectile 15 17 { 16 public:17 TestBullet ();18 virtual ~TestBullet ();18 public: 19 TestBullet (); 20 virtual ~TestBullet (); 19 21 20 virtual void collidesWith(WorldEntity* entity, const Vector& location);21 virtual void destroy ();22 22 23 virtual void tick (float time); 24 virtual void draw (); 23 virtual void activate(); 24 virtual void deactivate(); 25 26 virtual void collidesWith(WorldEntity* entity, const Vector& location); 27 28 virtual void destroy (); 29 30 virtual void tick (float time); 31 virtual void draw (); 32 33 34 private: 35 static ParticleSystem* explosionParticles; 36 ParticleEmitter* emitter; 25 37 26 38 }; -
trunk/src/world_entities/weapons/test_gun.cc
r5441 r5443 29 29 #include "factory.h" 30 30 31 #include "state.h"32 31 #include "vector.h" 33 32 #include "list.h" … … 189 188 pj->setAbsCoor(this->getEmissionPoint()); 190 189 pj->setAbsDir(this->getAbsDir()); 191 State::getWorldEntityList()->add(pj);190 pj->activate(); 192 191 } 193 192 -
trunk/src/world_entities/weapons/turret.cc
r5441 r5443 138 138 if (target != NULL) 139 139 { 140 pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND( 20)140 pj->setVelocity(this->getVelocity()+(this->getAbsDir().apply(Vector(1,0,0))*100.0 + VECTOR_RAND(13) 141 141 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 142 142 } … … 147 147 pj->setAbsCoor(this->getEmissionPoint()); 148 148 pj->setAbsDir(this->getAbsDir()); 149 150 State::getWorldEntityList()->add(pj); 149 pj->activate(); 151 150 } 152 151
Note: See TracChangeset
for help on using the changeset viewer.