Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10409


Ignore:
Timestamp:
Apr 30, 2015, 4:47:36 PM (10 years ago)
Author:
meggiman
Message:

Started implementing Particle effect. Force Field explodes at end of life.

Location:
code/branches/weaponFS15/src/modules/weapons/projectiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc

    r10391 r10409  
    1212        RegisterClass(GravityBombField);
    1313
    14         const float GravityBombField::FORCE_FIELD_LIFETIME = 100;
    15         const float GravityBombField::FORCE_SPHERE_START_RADIUS = 500;
     14        const float GravityBombField::FORCE_FIELD_LIFETIME = 20;
     15        const float GravityBombField::FORCE_SPHERE_START_RADIUS = 250;
    1616        const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
    1717
    18         GravityBombField::GravityBombField(Context* context) : ForceField(context)
     18        GravityBombField::GravityBombField(Context* context) : ForceField(context),RadarViewable(this, static_cast<WorldEntity*>(this))
    1919        {
    2020                RegisterObject(GravityBombField);
    2121                lifetime_=FORCE_FIELD_LIFETIME;
     22                forceStrength_ = FORCE_SPHERE_START_STRENGTH;
     23                forceSphereRadius_ = FORCE_SPHERE_START_RADIUS;
     24                fieldExploded_ = false;
     25
    2226                setVelocity(FORCE_SPHERE_START_STRENGTH);
    23                 setDiameter(FORCE_SPHERE_START_RADIUS);
    24                 setMode(modeInvertedSphere_s);
     27                setDiameter(2*FORCE_SPHERE_START_RADIUS);
     28                setMode(modeSphere_s);
    2529                setCollisionResponse(false);
     30
     31                this->setRadarObjectColour(ColourValue(0.2, 0.2, 1.0,1)); // Blue
     32                this->setRadarObjectShape(RadarViewable::Dot);
     33                this->setRadarObjectScale(0.5f);
    2634
    2735                //Attach Demo Model for debuging.
     
    3038                        model->scale(0.7f);
    3139                        this->attach(model);
     40
     41                this->particleSphere_ = new ParticleEmitter(this->getContext());
     42                this->attach(this->particleSphere_);
     43
     44                particleSphere_->setSource("Orxonox/GravityBombField");
    3245        }
    3346
     
    3851                SUPER(GravityBombField,tick,dt);
    3952                lifetime_-=dt;
     53                forceStrength_ *= (1+dt/10);
     54                if(lifetime_ < 0.2 && !fieldExploded_)
     55                {
     56                        forceStrength_ *= -2;
     57                        forceSphereRadius_ *= 2;
     58                        fieldExploded_ = true;
     59                        orxout(debug_output) << "Field exploded. Inverting Force." << endl;
     60                }
     61
     62                setDiameter(forceSphereRadius_*2);
     63                setVelocity(forceStrength_);
     64
    4065                if(lifetime_ < 0)
    4166                {
  • code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h

    r10341 r10409  
    1616#include "core/CoreIncludes.h"
    1717#include "GravityBomb.h"
     18#include "graphics/ParticleSpawner.h"
     19
    1820
    1921namespace orxonox {
    20 class GravityBombField: public ForceField {
     22class GravityBombField: public ForceField, public RadarViewable {
    2123public:
    2224        GravityBombField(Context* context);
     
    3234        float forceStrength_;
    3335        float lifetime_;
     36        bool fieldExploded_;
     37        ParticleEmitter * particleSphere_;
    3438
    3539};
Note: See TracChangeset for help on using the changeset viewer.