Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7128 was 7086, checked in by bensch, 19 years ago

Destroy Sounds

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