Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

weaponAdjustment

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 "box_emitter.h"
26#include "spark_particles.h"
27
28
29using namespace std;
30
31CREATE_FAST_FACTORY_STATIC(Hyperblast, CL_HYPERBLAST);
32
33/**
34 *  standard constructor
35*/
36Hyperblast::Hyperblast () : Projectile()
37{
38  this->setClassID(CL_HYPERBLAST, "Hyperblast");
39
40  float modelSize = .3;
41  this->loadModel("models/projectiles/hyperblast.obj", 5);
42
43  this->setMinEnergy(50);
44  this->setHealthMax(1000);
45  this->lifeSpan = 1;
46  this->size = 4.0;
47
48  this->emitter = new BoxEmitter(Vector(400, 2, 2), 100, 5, M_2_PI);
49  this->emitter->setRelCoor(200,0,0);
50  this->emitter->setParent(this);
51  this->emitter->setSpread(M_PI, M_PI);
52}
53
54
55/**
56 *  standard deconstructor
57*/
58Hyperblast::~Hyperblast ()
59{
60  /* this is normaly done by World.cc by deleting the ParticleEngine */
61  if (Hyperblast::explosionParticles != NULL && ClassList::getList(CL_HYPERBLAST)->size() <= 1)
62  {
63    Hyperblast::explosionParticles = NULL;
64  }
65
66}
67
68SparkParticles* Hyperblast::explosionParticles = NULL;
69
70void Hyperblast::activate()
71{
72  if (unlikely(Hyperblast::explosionParticles == NULL))
73  {
74    Hyperblast::explosionParticles = new SparkParticles(2000);
75    Hyperblast::explosionParticles->setName("HyperblastExplosionParticles");
76    Hyperblast::explosionParticles->setLifeSpan(2, .3);
77    Hyperblast::explosionParticles->setRadius(0.1, .1);
78    Hyperblast::explosionParticles->setRadius(0.2, .2);
79    Hyperblast::explosionParticles->setRadius(1.0, .1);
80    Hyperblast::explosionParticles->setColor(0.0, 1.0, .6, 0 ,1);
81    Hyperblast::explosionParticles->setColor(0.5, .8,.1,0,.6);
82    Hyperblast::explosionParticles->setColor(0.8, .8,.2,.3,.3);
83    Hyperblast::explosionParticles->setColor(1.0, 1,1,1,.0);
84  }
85
86  this->emitter->setSystem(Hyperblast::explosionParticles);
87  this->size = 4.0;
88
89  Hyperblast::explosionParticles->debug();
90  this->updateNode(0);
91  this->emitter->setEmissionRate(5000.0);
92  this->emitter->setEmissionVelocity(50.0);
93
94  this->setHealth(200);
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  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
Note: See TracBrowser for help on using the repository browser.