Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Oct 30, 2005, 12:54:23 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: added Lasers and Rockets Class as TestBullet is not the best Name

Location:
trunk/src/world_entities/weapons
Files:
2 edited
4 copied

Legend:

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

    r5451 r5456  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1717
    18 #include "test_bullet.h"
     18#include "laser.h"
    1919
    2020#include "fast_factory.h"
     
    3131using namespace std;
    3232
    33 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET);
     33CREATE_FAST_FACTORY_STATIC(Laser, CL_LASER);
    3434
    3535/**
    3636 *  standard constructor
    3737*/
    38 TestBullet::TestBullet () : Projectile()
     38Laser::Laser () : Projectile()
    3939{
    40   this->setClassID(CL_TEST_BULLET, "TestBullet");
     40  this->setClassID(CL_TEST_BULLET, "Laser");
    4141
    4242  float modelSize = .3;
    43   this->loadModelWithScale("models/projectiles/orx-rocket.obj", .3);
     43  this->loadModelWithScale("models/projectiles/lasers.obj", .3);
    4444
    4545  this->energyMin = 1;
     
    5151  this->emitter->setParent(this);
    5252  this->emitter->setSpread(M_PI, M_PI);
     53  this->emitter->setEmissionRate(30.0);
     54  this->emitter->setEmissionVelocity(50.0);
    5355}
    5456
     
    5759 *  standard deconstructor
    5860*/
    59 TestBullet::~TestBullet ()
     61Laser::~Laser ()
    6062{
    6163  // delete this->emitter;
    6264
    6365  /* this is normaly done by World.cc by deleting the ParticleEngine */
    64   if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     66  if (Laser::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
    6567  {
    66     if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM))
    67       delete TestBullet::trailParticles;
    68     TestBullet::trailParticles = NULL;
    69   }
    70   if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
    71   {
    72     if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))
    73       delete TestBullet::explosionParticles;
    74     TestBullet::explosionParticles = NULL;
     68    if (ClassList::exists(Laser::explosionParticles, CL_PARTICLE_SYSTEM))
     69      delete Laser::explosionParticles;
     70    Laser::explosionParticles = NULL;
    7571  }
    7672
    7773}
    7874
    79 ParticleSystem* TestBullet::trailParticles = NULL;
    80 ParticleSystem* TestBullet::explosionParticles = NULL;
     75ParticleSystem* Laser::explosionParticles = NULL;
    8176
    82 void TestBullet::activate()
     77void Laser::activate()
    8378{
    8479  State::getWorldEntityList()->add(this);
    85   if (unlikely(TestBullet::trailParticles == NULL))
     80  if (unlikely(Laser::explosionParticles == NULL))
    8681  {
    87     TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
    88     TestBullet::trailParticles->setName("TestBulletTrailParticles");
    89     TestBullet::trailParticles->setLifeSpan(.5, .3);
    90     TestBullet::trailParticles->setRadius(0.0, .5);
    91     TestBullet::trailParticles->setRadius(0.5, 2.0);
    92     TestBullet::trailParticles->setRadius(1.0, 5.0);
    93     TestBullet::trailParticles->setColor(0.0, 1,0,0,.7);
    94     TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5);
    95     TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0);
     82    Laser::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
     83    Laser::explosionParticles->setName("LaserExplosionParticles");
     84    Laser::explosionParticles->setLifeSpan(.5, .3);
     85    Laser::explosionParticles->setRadius(0.0, 10);
     86    Laser::explosionParticles->setRadius(.5, 20.0);
     87    Laser::explosionParticles->setRadius(1.0, 3.0);
     88    Laser::explosionParticles->setColor(0.0, 0,1,0,.9);
     89    Laser::explosionParticles->setColor(0.5, .8,.8,0,.5);
     90    Laser::explosionParticles->setColor(1.0, 1,1,1,.0);
    9691  }
    97   if (unlikely(TestBullet::explosionParticles == NULL))
    98   {
    99     TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
    100     TestBullet::explosionParticles->setName("TestBulletExplosionParticles");
    101     TestBullet::explosionParticles->setLifeSpan(.5, .3);
    102     TestBullet::explosionParticles->setRadius(0.0, 10);
    103     TestBullet::explosionParticles->setRadius(.5, 20.0);
    104     TestBullet::explosionParticles->setRadius(1.0, 3.0);
    105     TestBullet::explosionParticles->setColor(0.0, 0,1,0,.9);
    106     TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);
    107     TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0);
    108   }
    109 
    110   ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles);
    111 
    112   this->emitter->setEmissionRate(20.0);
    113   this->emitter->setEmissionVelocity(3.0);
    11492}
    11593
    11694
    117 void TestBullet::deactivate()
     95void Laser::deactivate()
    11896{
    11997  ParticleEngine::getInstance()->breakConnections(this->emitter);
     
    122100//  GarbageCollector::getInstance()->collect(this);
    123101  State::getWorldEntityList()->remove(this);
    124   TestBullet::fastFactory->kill(this);
     102  Laser::fastFactory->kill(this);
    125103}
    126104
    127105
    128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)
     106void Laser::collidesWith(WorldEntity* entity, const Vector& location)
    129107{
    130108  if (this->hitEntity != entity && entity->isA(CL_NPC))
     
    137115 * @param time since last tick
    138116*/
    139 void TestBullet::tick (float time)
     117void Laser::tick (float time)
    140118{
    141119  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
     
    157135 *  the function gets called, when the projectile is destroyed
    158136*/
    159 void TestBullet::destroy ()
     137void Laser::destroy ()
    160138{
    161   PRINTF(5)("DESTROY TestBullet\n");
     139  PRINTF(5)("DESTROY Laser\n");
    162140  this->lifeCycle = .95; //!< @todo calculate this usefully.
    163   ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles);
    164   ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles);
    165 
    166   this->emitter->setEmissionRate(30.0);
    167   this->emitter->setEmissionVelocity(50.0);
    168 //  this->deactivate();
     141  ParticleEngine::getInstance()->addConnection(this->emitter, Laser::explosionParticles);
    169142
    170143}
    171144
    172145
    173 void TestBullet::draw ()
     146void Laser::draw ()
    174147{
    175148  glMatrixMode(GL_MODELVIEW);
  • trunk/src/world_entities/weapons/laser.h

    r5449 r5456  
    11/*!
    2     \projectile.h
    3   * a projectile, that is been shooted by a weapon
     2 * @file laser.h
     3 * @brief a projectile, that is been shooted by a weapon
    44*/
    55
    6 #ifndef _TEST_BULLET_H
    7 #define _TEST_BULLET_H
     6#ifndef _LASER_H
     7#define _LASER_H
    88
    99#include "projectile.h"
     
    1515class FastFactory;
    1616
    17 class TestBullet : public Projectile
     17class Laser : public Projectile
    1818{
    1919  public:
    20     TestBullet ();
    21     virtual ~TestBullet ();
     20    Laser ();
     21    virtual ~Laser ();
    2222
    2323
     
    3535  private:
    3636    static FastFactory*               fastFactory;
    37     static ParticleSystem*            trailParticles;
     37
    3838    static ParticleSystem*            explosionParticles;
    3939
     
    4545};
    4646
    47 #endif /* _TEST_BULLET_H */
     47#endif /* _LASER_H */
  • trunk/src/world_entities/weapons/rocket.cc

    r5451 r5456  
    1616#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WEAPON
    1717
    18 #include "test_bullet.h"
     18#include "rocket.h"
    1919
    2020#include "fast_factory.h"
     
    3131using namespace std;
    3232
    33 CREATE_FAST_FACTORY_STATIC(TestBullet, CL_TEST_BULLET);
     33CREATE_FAST_FACTORY_STATIC(Rocket, CL_ROCKET);
    3434
    3535/**
    3636 *  standard constructor
    3737*/
    38 TestBullet::TestBullet () : Projectile()
     38Rocket::Rocket () : Projectile()
    3939{
    40   this->setClassID(CL_TEST_BULLET, "TestBullet");
     40  this->setClassID(CL_TEST_BULLET, "Rocket");
    4141
    4242  float modelSize = .3;
     
    5757 *  standard deconstructor
    5858*/
    59 TestBullet::~TestBullet ()
     59Rocket::~Rocket ()
    6060{
    6161  // delete this->emitter;
    6262
    6363  /* this is normaly done by World.cc by deleting the ParticleEngine */
    64   if (TestBullet::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     64  if (Rocket::trailParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
    6565  {
    66     if (ClassList::exists(TestBullet::trailParticles, CL_PARTICLE_SYSTEM))
    67       delete TestBullet::trailParticles;
    68     TestBullet::trailParticles = NULL;
     66    if (ClassList::exists(Rocket::trailParticles, CL_PARTICLE_SYSTEM))
     67      delete Rocket::trailParticles;
     68    Rocket::trailParticles = NULL;
    6969  }
    70   if (TestBullet::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
     70  if (Rocket::explosionParticles != NULL && ClassList::getList(CL_TEST_BULLET)->getSize() <= 1)
    7171  {
    72     if (ClassList::exists(TestBullet::explosionParticles, CL_PARTICLE_SYSTEM))
    73       delete TestBullet::explosionParticles;
    74     TestBullet::explosionParticles = NULL;
     72    if (ClassList::exists(Rocket::explosionParticles, CL_PARTICLE_SYSTEM))
     73      delete Rocket::explosionParticles;
     74    Rocket::explosionParticles = NULL;
    7575  }
    7676
    7777}
    7878
    79 ParticleSystem* TestBullet::trailParticles = NULL;
    80 ParticleSystem* TestBullet::explosionParticles = NULL;
     79ParticleSystem* Rocket::trailParticles = NULL;
     80ParticleSystem* Rocket::explosionParticles = NULL;
    8181
    82 void TestBullet::activate()
     82void Rocket::activate()
    8383{
    8484  State::getWorldEntityList()->add(this);
    85   if (unlikely(TestBullet::trailParticles == NULL))
     85  if (unlikely(Rocket::trailParticles == NULL))
    8686  {
    87     TestBullet::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
    88     TestBullet::trailParticles->setName("TestBulletTrailParticles");
    89     TestBullet::trailParticles->setLifeSpan(.5, .3);
    90     TestBullet::trailParticles->setRadius(0.0, .5);
    91     TestBullet::trailParticles->setRadius(0.5, 2.0);
    92     TestBullet::trailParticles->setRadius(1.0, 5.0);
    93     TestBullet::trailParticles->setColor(0.0, 1,0,0,.7);
    94     TestBullet::trailParticles->setColor(0.5, .8,.8,0,.5);
    95     TestBullet::trailParticles->setColor(1.0, .7,.7,.7,.0);
     87    Rocket::trailParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
     88    Rocket::trailParticles->setName("RocketTrailParticles");
     89    Rocket::trailParticles->setLifeSpan(.5, .3);
     90    Rocket::trailParticles->setRadius(0.0, .5);
     91    Rocket::trailParticles->setRadius(0.5, 2.0);
     92    Rocket::trailParticles->setRadius(1.0, 5.0);
     93    Rocket::trailParticles->setColor(0.0, 1,0,0,.7);
     94    Rocket::trailParticles->setColor(0.5, .8,.8,0,.5);
     95    Rocket::trailParticles->setColor(1.0, .7,.7,.7,.0);
    9696  }
    97   if (unlikely(TestBullet::explosionParticles == NULL))
     97  if (unlikely(Rocket::explosionParticles == NULL))
    9898  {
    99     TestBullet::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
    100     TestBullet::explosionParticles->setName("TestBulletExplosionParticles");
    101     TestBullet::explosionParticles->setLifeSpan(.5, .3);
    102     TestBullet::explosionParticles->setRadius(0.0, 10);
    103     TestBullet::explosionParticles->setRadius(.5, 20.0);
    104     TestBullet::explosionParticles->setRadius(1.0, 3.0);
    105     TestBullet::explosionParticles->setColor(0.0, 0,1,0,.9);
    106     TestBullet::explosionParticles->setColor(0.5, .8,.8,0,.5);
    107     TestBullet::explosionParticles->setColor(1.0, 1,1,1,.0);
     99    Rocket::explosionParticles = new ParticleSystem(1000, PARTICLE_SPRITE);
     100    Rocket::explosionParticles->setName("RocketExplosionParticles");
     101    Rocket::explosionParticles->setLifeSpan(.5, .3);
     102    Rocket::explosionParticles->setRadius(0.0, 10);
     103    Rocket::explosionParticles->setRadius(.5, 20.0);
     104    Rocket::explosionParticles->setRadius(1.0, 3.0);
     105    Rocket::explosionParticles->setColor(0.0, 0,1,0,.9);
     106    Rocket::explosionParticles->setColor(0.5, .8,.8,0,.5);
     107    Rocket::explosionParticles->setColor(1.0, 1,1,1,.0);
    108108  }
    109109
    110   ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::trailParticles);
     110  ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::trailParticles);
    111111
    112112  this->emitter->setEmissionRate(20.0);
     
    115115
    116116
    117 void TestBullet::deactivate()
     117void Rocket::deactivate()
    118118{
    119119  ParticleEngine::getInstance()->breakConnections(this->emitter);
     
    122122//  GarbageCollector::getInstance()->collect(this);
    123123  State::getWorldEntityList()->remove(this);
    124   TestBullet::fastFactory->kill(this);
     124  Rocket::fastFactory->kill(this);
    125125}
    126126
    127127
    128 void TestBullet::collidesWith(WorldEntity* entity, const Vector& location)
     128void Rocket::collidesWith(WorldEntity* entity, const Vector& location)
    129129{
    130130  if (this->hitEntity != entity && entity->isA(CL_NPC))
     
    137137 * @param time since last tick
    138138*/
    139 void TestBullet::tick (float time)
     139void Rocket::tick (float time)
    140140{
    141141  //Vector v = *this->flightDirection * ( this->speed * time * 1000 + 0.1);
     
    157157 *  the function gets called, when the projectile is destroyed
    158158*/
    159 void TestBullet::destroy ()
     159void Rocket::destroy ()
    160160{
    161   PRINTF(5)("DESTROY TestBullet\n");
     161  PRINTF(5)("DESTROY Rocket\n");
    162162  this->lifeCycle = .95; //!< @todo calculate this usefully.
    163   ParticleEngine::getInstance()->breakConnection(this->emitter, TestBullet::trailParticles);
    164   ParticleEngine::getInstance()->addConnection(this->emitter, TestBullet::explosionParticles);
     163  ParticleEngine::getInstance()->breakConnection(this->emitter, Rocket::trailParticles);
     164  ParticleEngine::getInstance()->addConnection(this->emitter, Rocket::explosionParticles);
    165165
    166166  this->emitter->setEmissionRate(30.0);
     
    171171
    172172
    173 void TestBullet::draw ()
     173void Rocket::draw ()
    174174{
    175175  glMatrixMode(GL_MODELVIEW);
  • trunk/src/world_entities/weapons/rocket.h

    r5449 r5456  
    11/*!
    2     \projectile.h
    3   *  a projectile, that is been shooted by a weapon
     2 * @file rocket.h
     3 * @brief a Rocket Projectile
    44*/
    55
    6 #ifndef _TEST_BULLET_H
    7 #define _TEST_BULLET_H
     6#ifndef _ROCKET_H
     7#define _ROCKET_H
    88
    99#include "projectile.h"
     
    1515class FastFactory;
    1616
    17 class TestBullet : public Projectile
     17class Rocket : public Projectile
    1818{
    1919  public:
    20     TestBullet ();
    21     virtual ~TestBullet ();
     20    Rocket ();
     21    virtual ~Rocket ();
    2222
    2323
     
    4545};
    4646
    47 #endif /* _TEST_BULLET_H */
     47#endif /* _ROCKET_H */
  • trunk/src/world_entities/weapons/test_gun.cc

    r5443 r5456  
    134134
    135135  this->setCapability(WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    136   this->setProjectileType(CL_TEST_BULLET);
     136  this->setProjectileType(CL_LASER);
    137137  this->prepareProjectiles(20);
    138138}
  • trunk/src/world_entities/weapons/turret.cc

    r5443 r5456  
    9292
    9393  this->setCapability(WTYPE_ALLDIRS | WTYPE_TURRET);
    94   this->setProjectileType(CL_TEST_BULLET);
     94  this->setProjectileType(CL_ROCKET);
    9595
    9696
Note: See TracChangeset for help on using the changeset viewer.