[4593] | 1 | /* |
---|
[3708] | 2 | orxonox - the future of 3D-vertical-scrollers |
---|
| 3 | |
---|
| 4 | Copyright (C) 2004 orx |
---|
| 5 | |
---|
| 6 | This program is free software; you can redistribute it and/or modify |
---|
| 7 | it under the terms of the GNU General Public License as published by |
---|
| 8 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 9 | any later version. |
---|
| 10 | |
---|
| 11 | ### File Specific |
---|
[6810] | 12 | main-programmer: Benjamin Grauer |
---|
| 13 | co-programmer: ... |
---|
[5443] | 14 | |
---|
[3708] | 15 | */ |
---|
[5357] | 16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON |
---|
[3708] | 17 | |
---|
[6810] | 18 | #include "hyperblast.h" |
---|
[3708] | 19 | |
---|
[4947] | 20 | #include "fast_factory.h" |
---|
[3708] | 21 | |
---|
[5443] | 22 | #include "state.h" |
---|
[5444] | 23 | #include "class_list.h" |
---|
[5054] | 24 | |
---|
[5443] | 25 | #include "particle_emitter.h" |
---|
[6621] | 26 | #include "sprite_particles.h" |
---|
[6810] | 27 | #include "spark_particles.h" |
---|
[5443] | 28 | |
---|
| 29 | |
---|
[3708] | 30 | using namespace std; |
---|
| 31 | |
---|
[6810] | 32 | CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST); |
---|
[3708] | 33 | |
---|
| 34 | /** |
---|
[4836] | 35 | * standard constructor |
---|
[3708] | 36 | */ |
---|
[6810] | 37 | Hyperblast::Hyperblast () : Projectile() |
---|
[3755] | 38 | { |
---|
[6810] | 39 | this->setClassID(CL_HYPERBLAST, "Hyperblast"); |
---|
[4597] | 40 | |
---|
[4948] | 41 | float modelSize = .3; |
---|
[6811] | 42 | this->loadModel("models/projectiles/hyperblast.obj", 5); |
---|
[4948] | 43 | |
---|
[6431] | 44 | this->setMinEnergy(1); |
---|
[6700] | 45 | this->setHealthMax(10); |
---|
[5819] | 46 | this->lifeSpan = 5; |
---|
[5443] | 47 | |
---|
[5447] | 48 | this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5); |
---|
[5443] | 49 | this->emitter->setParent(this); |
---|
[5449] | 50 | this->emitter->setSpread(M_PI, M_PI); |
---|
[3755] | 51 | } |
---|
[3708] | 52 | |
---|
| 53 | |
---|
| 54 | /** |
---|
[4836] | 55 | * standard deconstructor |
---|
[3708] | 56 | */ |
---|
[6810] | 57 | Hyperblast::~Hyperblast () |
---|
[3708] | 58 | { |
---|
[5445] | 59 | /* this is normaly done by World.cc by deleting the ParticleEngine */ |
---|
[6810] | 60 | if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1) |
---|
[5444] | 61 | { |
---|
[6810] | 62 | Hyperblast::explosionParticles = NULL; |
---|
[5444] | 63 | } |
---|
[5445] | 64 | |
---|
[3708] | 65 | } |
---|
| 66 | |
---|
[6810] | 67 | SparkParticles* Hyperblast::explosionParticles = NULL; |
---|
[5443] | 68 | |
---|
[6810] | 69 | void Hyperblast::activate() |
---|
[5443] | 70 | { |
---|
[6810] | 71 | if (unlikely(Hyperblast::explosionParticles == NULL)) |
---|
[5443] | 72 | { |
---|
[6813] | 73 | Hyperblast::explosionParticles = new SparkParticles(2000); |
---|
[6810] | 74 | Hyperblast::explosionParticles->setName("HyperblastExplosionParticles"); |
---|
[6813] | 75 | Hyperblast::explosionParticles->setLifeSpan(5, .3); |
---|
| 76 | Hyperblast::explosionParticles->setRadius(100.0, 10); |
---|
| 77 | Hyperblast::explosionParticles->setRadius(20, 15.0); |
---|
| 78 | Hyperblast::explosionParticles->setRadius(50.0, 10.0); |
---|
[6810] | 79 | Hyperblast::explosionParticles->setColor(0.0, 0,1,0,1); |
---|
[6813] | 80 | Hyperblast::explosionParticles->setColor(0.5, .8,.8,0,.99); |
---|
| 81 | Hyperblast::explosionParticles->setColor(0.8, .8,.8,.3,.99); |
---|
[6810] | 82 | Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0); |
---|
[5443] | 83 | } |
---|
| 84 | |
---|
[6811] | 85 | this->emitter->setSystem(Hyperblast::explosionParticles); |
---|
[5447] | 86 | |
---|
[6813] | 87 | Hyperblast::explosionParticles->debug(); |
---|
[5769] | 88 | this->updateNode(0); |
---|
[6811] | 89 | this->emitter->setEmissionRate(245.0); |
---|
[6813] | 90 | this->emitter->setEmissionVelocity(10.0); |
---|
[5443] | 91 | } |
---|
| 92 | |
---|
| 93 | |
---|
[6810] | 94 | void Hyperblast::deactivate() |
---|
[5443] | 95 | { |
---|
[6619] | 96 | this->emitter->setSystem(NULL); |
---|
[5447] | 97 | this->lifeCycle = 0.0; |
---|
[6142] | 98 | this->toList(OM_NULL); |
---|
[5443] | 99 | |
---|
[5447] | 100 | // GarbageCollector::getInstance()->collect(this); |
---|
[6142] | 101 | this->toList(OM_DEAD); |
---|
[6810] | 102 | Hyperblast::fastFactory->kill(this); |
---|
[5443] | 103 | } |
---|
| 104 | |
---|
| 105 | |
---|
[6810] | 106 | void Hyperblast::collidesWith(WorldEntity* entity, const Vector& location) |
---|
[5257] | 107 | { |
---|
| 108 | } |
---|
[3708] | 109 | |
---|
| 110 | /** |
---|
[4836] | 111 | * signal tick, time dependent things will be handled here |
---|
| 112 | * @param time since last tick |
---|
[3708] | 113 | */ |
---|
[6810] | 114 | void Hyperblast::tick (float dt) |
---|
[3708] | 115 | { |
---|
[6056] | 116 | if(this->tickLifeCycle(dt)) |
---|
| 117 | this->deactivate(); |
---|
[3708] | 118 | } |
---|
| 119 | |
---|
| 120 | /** |
---|
[4836] | 121 | * the function gets called, when the projectile is destroyed |
---|
[3708] | 122 | */ |
---|
[6810] | 123 | void Hyperblast::destroy () |
---|
[5257] | 124 | { |
---|
[6810] | 125 | PRINTF(5)("DESTROY Hyperblast\n"); |
---|
[3708] | 126 | |
---|
| 127 | |
---|
[5257] | 128 | } |
---|
| 129 | |
---|
| 130 | |
---|
[6810] | 131 | void Hyperblast::draw () const |
---|
[3708] | 132 | { |
---|
| 133 | glMatrixMode(GL_MODELVIEW); |
---|
| 134 | glPushMatrix(); |
---|
| 135 | |
---|
[4593] | 136 | float matrix[4][4]; |
---|
[3708] | 137 | glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z); |
---|
| 138 | this->getAbsDir().matrix (matrix); |
---|
[4593] | 139 | glMultMatrixf((float*)matrix); |
---|
[3755] | 140 | glScalef(2.0, 2.0, 2.0); |
---|
[5994] | 141 | this->getModel()->draw(); |
---|
[3708] | 142 | |
---|
| 143 | glPopMatrix(); |
---|
| 144 | } |
---|
| 145 | |
---|