Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

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 "state.h"
21#include "class_list.h"
22
23#include "box_emitter.h"
24#include "spark_particles.h"
25
26#include "debug.h"
27
28CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST);
29
30/**
31 *  standard constructor
32*/
33Hyperblast::Hyperblast () : Projectile()
34{
35  this->setClassID(CL_HYPERBLAST, "Hyperblast");
36
37  this->loadModel("models/projectiles/hyperblast.obj", 5);
38
39  this->setMinEnergy(50);
40  this->setHealthMax(1000);
41  this->lifeSpan = 1;
42  this->size = 4.0;
43
44  this->emitter = new BoxEmitter(Vector(400, 2, 2), 100, 5, M_2_PI);
45  this->emitter->setRelCoor(200,0,0);
46  this->emitter->setParent(this);
47  this->emitter->setSpread(M_PI, M_PI);
48}
49
50
51/**
52 *  standard deconstructor
53*/
54Hyperblast::~Hyperblast ()
55{
56  /* this is normaly done by World.cc by deleting the ParticleEngine */
57  if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)
58  {
59    Hyperblast::explosionParticles = NULL;
60  }
61
62}
63
64SparkParticles* Hyperblast::explosionParticles = NULL;
65
66void Hyperblast::activate()
67{
68  if (unlikely(Hyperblast::explosionParticles == NULL))
69  {
70    Hyperblast::explosionParticles = new SparkParticles(2000);
71    Hyperblast::explosionParticles->setName("HyperblastExplosionParticles");
72    Hyperblast::explosionParticles->setLifeSpan(2, .3);
73    Hyperblast::explosionParticles->setRadius(0.1, .1);
74    Hyperblast::explosionParticles->setRadius(0.2, .2);
75    Hyperblast::explosionParticles->setRadius(1.0, .1);
76    Hyperblast::explosionParticles->setColor(0.0, 1.0, .6, 0 ,1);
77    Hyperblast::explosionParticles->setColor(0.5, .8,.1,0,.6);
78    Hyperblast::explosionParticles->setColor(0.8, .8,.2,.3,.3);
79    Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0);
80  }
81
82  this->emitter->setSystem(Hyperblast::explosionParticles);
83  this->size = 4.0;
84
85  Hyperblast::explosionParticles->debug();
86  this->updateNode(0);
87  this->emitter->setEmissionRate(5000.0);
88  this->emitter->setEmissionVelocity(50.0);
89
90  this->setHealth(200);
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  this->size *=(1 - (5.0*dt));
120
121  if (this->lifeCycle > .1 && this->emitter->getEmissionRate() > 10.0)
122    this->emitter->setEmissionRate(0.0);
123}
124
125/**
126 *  the function gets called, when the projectile is destroyed
127*/
128void Hyperblast::destroy ()
129{
130  Projectile::destroy();
131
132  PRINTF(5)("DESTROY Hyperblast\n");
133
134
135}
136
137
138void Hyperblast::draw () const
139{
140  if (this->lifeCycle < .1)
141  {
142  glMatrixMode(GL_MODELVIEW);
143  glPushMatrix();
144
145  glTranslatef (this->getAbsCoor ().x,
146                this->getAbsCoor ().y,
147                this->getAbsCoor ().z);
148  Vector tmpRot = this->getAbsDir().getSpacialAxis();
149  glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z );
150
151//  glScalef(2.0, this->size, this->size);
152  this->getModel()->draw();
153
154  glPopMatrix();
155  }
156}
157
Note: See TracBrowser for help on using the repository browser.