Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 8319 was 8316, checked in by bensch, 19 years ago

trunk: fixed most -Wall warnings… but there are still many missing :/

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