Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10368 was 10114, checked in by patrick, 18 years ago

merged network back to trunk

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