Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 2, 2015, 4:08:52 PM (10 years ago)
Author:
meggiman
Message:

Started implementing GravityBombField

File:
1 edited

Legend:

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

    r10336 r10341  
    1111        RegisterClass(GravityBomb);
    1212
    13         const float GravityBomb::FUEL_START = 10;
    14         const float GravityBomb::FORCE_SPHERE_START_RADIUS = 30;
    15         const float GravityBomb::FORCE_SPHERE_START_STRENGTH = 100;
     13        const float GravityBomb::INITIAL_VELOCITY = 20;
     14        const float GravityBomb::SLOW_DOWN_RATIO = 2;
    1615
    1716        GravityBomb::GravityBomb(Context* context):
    18                         BasicProjectile(),
    19                         MovableEntity(context),
    20                         RadarViewable(this,static_cast<WorldEntity*>(this))
     17                                BasicProjectile(),
     18                                MovableEntity(context),
     19                                RadarViewable(this,static_cast<WorldEntity*>(this))
    2120                {
    2221                        RegisterObject(GravityBomb);
    23                         this->lifetime_=FUEL_START;
    24                         this->forceSphereRadius_= FORCE_SPHERE_START_RADIUS;
    25                         this->forceStrength_ = FORCE_SPHERE_START_STRENGTH;
    2622
    27                         ForceField* field = new ForceField(context);
    28                         field->setMode("sphere");
    29                         field->setDiameter(this->forceSphereRadius_);
    30                         field->setVelocity(this->forceStrength_);
    31                         this->attach(field);
     23                        this->setMass(15.0);
     24                        if (GameMode::isMaster())
     25                        {
     26                                //Define movement of the bomb
     27                                this->setVelocity(this->getOrientation()*WorldEntity::FRONT*INITIAL_VELOCITY);
     28                                this->velocityAtLastTick_=INITIAL_VELOCITY;
     29                                this->setAcceleration(this->getOrientation()*WorldEntity::BACK*SLOW_DOWN_RATIO);
     30                                this->setCollisionType(WorldEntity::Dynamic);
     31                                this->enableCollisionCallback();
    3232
     33                                //Add Collision Shape
     34                                SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
     35                                collisionShape->setRadius(5.0);
     36                                this->attachCollisionShape(collisionShape);
     37
     38                                //Create Bomb Model
     39
     40
     41                        }
    3342                }
    3443
     
    3746        void GravityBomb::tick(float dt)
    3847        {
    39 
     48                        if(velocityAtLastTick_ < this->getVelocity().length())
     49                        {
     50                                setVelocity(Vector3::ZERO);
     51                                setAcceleration(Vector3::ZERO);
     52                                velocityAtLastTick_=0;
     53                                detonate();
     54                        }
     55                        velocityAtLastTick_=getVelocity().length();
    4056        }
    4157
    4258        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    4359        {
     60                detonate();
     61                processCollision(otherObject, contactPoint,cs);
    4462                return true;
     63        }
     64
     65        void GravityBomb::detonate()
     66        {
     67                GravityBombField* field = new GravityBombField(this->getContext());
    4568        }
    4669}
Note: See TracChangeset for help on using the changeset viewer.