Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5828 in orxonox.OLD for trunk/src/world_entities/weapons


Ignore:
Timestamp:
Nov 30, 2005, 12:14:15 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: bomb detonates

Location:
trunk/src/world_entities/weapons
Files:
3 edited

Legend:

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

    r5826 r5828  
    1818#include "state.h"
    1919#include "model.h"
     20#include "primitive_model.h"
     21
    2022#include "fast_factory.h"
    2123#include "list.h"
     
    5961Bomb::~Bomb ()
    6062{
     63  delete this->detonationSphere;
     64  delete this->detonationMaterial;
    6165
    6266}
     
    7175  this->setClassID(CL_BOMB, "Bomb");
    7276
     77
     78  this->detonationSphere = new PrimitiveModel(PRIM_SPHERE);
     79  this->detonationMaterial = new Material();
     80  this->detonationMaterial->setDiffuse(1, 0, 0);
     81  //   this->detonationMaterial->setTransparency(.1);
    7382  /**
    7483   * @todo: Write CL_PROTO_WORLD_ENTITY INTO THE src/defs/class_id.h (your own definition)
     
    101110void Bomb::tick(float time)
    102111{
    103   //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
    104   Vector v = this->velocity * (time);
    105   this->shiftCoor(v);
    106 
    107112  this->lifeCycle += time/this->lifeSpan;
    108113  if( this->lifeCycle >= 1.0)
     
    114119      this->deactivate();
    115120    }
    116     if (this->lifeCycle > 0.9f)
    117       this->detonate ((this->lifeCycle-.89) *10000.0);
     121  else if (this->lifeCycle > 0.9f)
     122    this->detonate ((this->lifeCycle-.89) *1000.0);
     123  else
     124  {
     125    Vector v = this->velocity * (time);
     126    this->shiftCoor(v);
     127  }
    118128}
    119129
     
    135145  glMultMatrixf((float*)matrix);
    136146
    137   if (model)
    138     model->draw();
     147  if (this->lifeCycle < .9)
     148  {
     149    if (model)
     150      model->draw();
     151  }
     152  else
     153  {
     154    glScalef((this->lifeCycle-.89) *1000.0,
     155              (this->lifeCycle-.89) *1000.0,
     156              (this->lifeCycle-.89) *1000.0);
     157    this->detonationMaterial->select();
     158    this->detonationSphere->draw();
     159  }
    139160  glPopMatrix();
    140161}
     
    147168void Bomb::collidesWith (WorldEntity* entity, const Vector& location)
    148169{
    149   if (entity->isA(CL_NPC))
    150     this->lifeSpan = 0.9f;
     170  if (this->lifeCycle < .9f && entity->isA(CL_NPC))
     171    this->lifeCycle = 0.9f;
    151172}
    152173
     
    160181{
    161182  State::getWorldEntityList()->remove(this);
     183  this->lifeCycle = 0.0f;
    162184  Bomb::fastFactory->kill(this);
    163185}
     
    170192    while( !detonationList->empty() )
    171193    {
    172     //detonationList->front()->collidesWith(this, Vector(0,0,0));
     194      detonationList->front()->collidesWith(this, Vector(0,0,0));
    173195      detonationList->pop_front();
    174196    }
  • trunk/src/world_entities/weapons/bomb.h

    r5826 r5828  
    88
    99#include "projectile.h"
     10
    1011class FastFactory;
    1112class ParticleSystem;
    1213class ParticleEmitter;
     14class Material;
    1315
    1416//! A Class to ...
     
    4143
    4244  ParticleEmitter*                  emitter;
    43 
     45  Model*                            detonationSphere;
     46  Material*                         detonationMaterial;
    4447};
    4548
  • trunk/src/world_entities/weapons/cannon.cc

    r5819 r5828  
    8383  this->setStateDuration(WS_DEACTIVATING, .4);
    8484
    85   this->setMaximumEnergy(100, 1);
    86   this->increaseEnergy(30);
     85  this->setMaximumEnergy(100, 20);
     86  this->increaseEnergy(100);
    8787  //this->minCharge = 2;
    8888
Note: See TracChangeset for help on using the changeset viewer.