Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6818 was 6813, checked in by bensch, 19 years ago

orxonox/trunk: particles, player etc.

File size: 3.3 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 = 5;
47
48  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
49  this->emitter->setParent(this);
50  this->emitter->setSpread(M_PI, M_PI);
51}
52
53
54/**
55 *  standard deconstructor
56*/
57Hyperblast::~Hyperblast ()
58{
59  /* this is normaly done by World.cc by deleting the ParticleEngine */
60  if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)
61  {
62    Hyperblast::explosionParticles = NULL;
63  }
64
65}
66
67SparkParticles* Hyperblast::explosionParticles = NULL;
68
69void Hyperblast::activate()
70{
71  if (unlikely(Hyperblast::explosionParticles == NULL))
72  {
73    Hyperblast::explosionParticles = new SparkParticles(2000);
74    Hyperblast::explosionParticles->setName("HyperblastExplosionParticles");
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);
79    Hyperblast::explosionParticles->setColor(0.0, 0,1,0,1);
80    Hyperblast::explosionParticles->setColor(0.5, .8,.8,0,.99);
81    Hyperblast::explosionParticles->setColor(0.8, .8,.8,.3,.99);
82    Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0);
83  }
84
85  this->emitter->setSystem(Hyperblast::explosionParticles);
86
87  Hyperblast::explosionParticles->debug();
88  this->updateNode(0);
89  this->emitter->setEmissionRate(245.0);
90  this->emitter->setEmissionVelocity(10.0);
91}
92
93
94void Hyperblast::deactivate()
95{
96  this->emitter->setSystem(NULL);
97  this->lifeCycle = 0.0;
98  this->toList(OM_NULL);
99
100//  GarbageCollector::getInstance()->collect(this);
101  this->toList(OM_DEAD);
102  Hyperblast::fastFactory->kill(this);
103}
104
105
106void Hyperblast::collidesWith(WorldEntity* entity, const Vector& location)
107{
108}
109
110/**
111 *  signal tick, time dependent things will be handled here
112 * @param time since last tick
113*/
114void Hyperblast::tick (float dt)
115{
116  if(this->tickLifeCycle(dt))
117    this->deactivate();
118}
119
120/**
121 *  the function gets called, when the projectile is destroyed
122*/
123void Hyperblast::destroy ()
124{
125  PRINTF(5)("DESTROY Hyperblast\n");
126
127
128}
129
130
131void Hyperblast::draw () const
132{
133  glMatrixMode(GL_MODELVIEW);
134  glPushMatrix();
135
136  float matrix[4][4];
137  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
138  this->getAbsDir().matrix (matrix);
139  glMultMatrixf((float*)matrix);
140  glScalef(2.0, 2.0, 2.0);
141  this->getModel()->draw();
142
143  glPopMatrix();
144}
145
Note: See TracBrowser for help on using the repository browser.