Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 23, 2005, 9:28:06 PM (18 years ago)
Author:
stefalie
Message:

da bomb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/world_entities/weapons/bomb.cc

    r5603 r5744  
    1616#include "bomb.h"
    1717#include "glincl.h"
     18#include "state.h"
     19#include "list.h"
    1820#include "model.h"
     21#include "vector.h"
    1922#include "fast_factory.h"
     23
     24
     25#include "particle_engine.h"
     26#include "particle_emitter.h"
     27#include "particle_system.h"
    2028
    2129using namespace std;
     
    3240  if (root != NULL)
    3341    this->loadParams(root);
     42
     43  float modelSize = 1.0;
     44  this->loadModel("models/projectiles/RadioActiveBomb.obj", 1.0);
     45
     46  this->energyMin = 1;
     47  this->energyMax = 1;
     48  this->remove();
     49  this->lifeSpan = 15;
     50
     51  this->emitter = new ParticleEmitter(Vector(0,1,0), M_2_PI, 100, 5);
     52  this->emitter->setParent(this);
     53  this->emitter->setSpread(M_PI, M_PI);
    3454}
    3555
     
    82102void Bomb::tick(float time)
    83103{
     104  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
     105  Vector v = this->velocity * (time);
     106  this->shiftCoor(v);
    84107
     108  this->lifeCycle += time/this->lifeSpan;
     109  if( this->lifeCycle >= 1.0)
     110    {
     111      PRINTF(5)("FINALIZE==========================\n");
     112      PRINTF(5)("current life cycle is: %f\n", this->lifeCycle);
     113      PRINTF(5)("FINALIZE===========================\n");
     114
     115      this->deactivate();
     116    }
    85117}
    86118
     
    114146void Bomb::collidesWith (WorldEntity* entity, const Vector& location)
    115147{
    116 
     148        this->detonate();
    117149}
    118150
    119151void Bomb::activate()
    120152{
     153  State::getWorldEntityList()->add(this);
    121154
    122155}
     
    124157void Bomb::deactivate()
    125158{
     159  State::getWorldEntityList()->remove(this);
     160  Bomb::fastFactory->kill(this);
     161}
    126162
     163void Bomb::detonate()
     164{
     165  tIterator<WorldEntity>* it = State::getWorldEntityList()->getIterator();
     166  WorldEntity* lm = it->firstElement();
     167
     168  while(lm != NULL)
     169  {
     170   
     171    lm = it->nextElement();
     172  }
    127173}
Note: See TracChangeset for help on using the changeset viewer.