Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/hyperblast.cc @ 6821

Last change on this file since 6821 was 6821, checked in by bensch, 18 years ago

trunk: HyperBlaster

File size: 3.6 KB
Line 
1/*
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
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14
15*/
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
17
18#include "hyperblast.h"
19
20#include "fast_factory.h"
21
22#include "state.h"
23#include "class_list.h"
24
25#include "particle_emitter.h"
26#include "sprite_particles.h"
27#include "spark_particles.h"
28
29
30using namespace std;
31
32CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST);
33
34/**
35 *  standard constructor
36*/
37Hyperblast::Hyperblast () : Projectile()
38{
39  this->setClassID(CL_HYPERBLAST, "Hyperblast");
40
41  float modelSize = .3;
42  this->loadModel("models/projectiles/hyperblast.obj", 5);
43
44  this->setMinEnergy(1);
45  this->setHealthMax(10);
46  this->lifeSpan = 1;
47  this->size = 4.0;
48
49  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
50  this->emitter->setType( EMITTER_CUBE );
51  this->emitter->setSize(10);
52  this->emitter->setParent(this);
53  this->emitter->setSpread(M_PI, M_PI);
54}
55
56
57/**
58 *  standard deconstructor
59*/
60Hyperblast::~Hyperblast ()
61{
62  /* this is normaly done by World.cc by deleting the ParticleEngine */
63  if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)
64  {
65    Hyperblast::explosionParticles = NULL;
66  }
67
68}
69
70SparkParticles* Hyperblast::explosionParticles = NULL;
71
72void Hyperblast::activate()
73{
74  if (unlikely(Hyperblast::explosionParticles == NULL))
75  {
76    Hyperblast::explosionParticles = new SparkParticles(2000);
77    Hyperblast::explosionParticles->setName("HyperblastExplosionParticles");
78    Hyperblast::explosionParticles->setLifeSpan(2, .3);
79    Hyperblast::explosionParticles->setRadius(0.1, .1);
80    Hyperblast::explosionParticles->setRadius(0.2, .2);
81    Hyperblast::explosionParticles->setRadius(1.0, .1);
82    Hyperblast::explosionParticles->setColor(0.0, 1.0, .6, 0 ,1);
83    Hyperblast::explosionParticles->setColor(0.5, .8,.1,0,.6);
84    Hyperblast::explosionParticles->setColor(0.8, .8,.2,.3,.3);
85    Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0);
86  }
87
88  this->emitter->setSystem(Hyperblast::explosionParticles);
89  this->size = 4.0;
90
91  Hyperblast::explosionParticles->debug();
92  this->updateNode(0);
93  this->emitter->setEmissionRate(5000.0);
94  this->emitter->setEmissionVelocity(50.0);
95}
96
97
98void Hyperblast::deactivate()
99{
100  this->emitter->setSystem(NULL);
101  this->lifeCycle = 0.0;
102  this->toList(OM_NULL);
103
104//  GarbageCollector::getInstance()->collect(this);
105  this->toList(OM_DEAD);
106  Hyperblast::fastFactory->kill(this);
107}
108
109
110void Hyperblast::collidesWith(WorldEntity* entity, const Vector& location)
111{
112}
113
114/**
115 *  signal tick, time dependent things will be handled here
116 * @param time since last tick
117*/
118void Hyperblast::tick (float dt)
119{
120  if(this->tickLifeCycle(dt))
121    this->deactivate();
122
123  this->size *=(1 - (5.0*dt));
124
125  if (this->lifeCycle > .1 && this->emitter->getEmissionRate() > 10.0)
126    this->emitter->setEmissionRate(0.0);
127}
128
129/**
130 *  the function gets called, when the projectile is destroyed
131*/
132void Hyperblast::destroy ()
133{
134  PRINTF(5)("DESTROY Hyperblast\n");
135
136
137}
138
139
140void Hyperblast::draw () const
141{
142  glMatrixMode(GL_MODELVIEW);
143  glPushMatrix();
144
145  float matrix[4][4];
146  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
147  this->getAbsDir().matrix (matrix);
148  glMultMatrixf((float*)matrix);
149  glScalef(2.0, this->size, this->size);
150  this->getModel()->draw();
151
152  glPopMatrix();
153}
154
Note: See TracBrowser for help on using the repository browser.