Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 16, 2015, 4:43:55 PM (9 years ago)
Author:
meggiman
Message:

Alle Klassen implementiert um die Waffe abzufeuern. Noch sehr fehlerhaft.

File:
1 edited

Legend:

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

    r10341 r10369  
    66 */
    77#include "GravityBomb.h"
     8#include "graphics/Model.h"
    89
    910
    1011namespace orxonox{
    1112        RegisterClass(GravityBomb);
    12 
    13         const float GravityBomb::INITIAL_VELOCITY = 20;
    14         const float GravityBomb::SLOW_DOWN_RATIO = 2;
    1513
    1614        GravityBomb::GravityBomb(Context* context):
     
    2422                        if (GameMode::isMaster())
    2523                        {
    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);
     24                                //Define CollisionType of the bomb
     25                                this->velocityAtLastTick_= 1000;
     26                                this->setCollisionResponse(false);
     27                                this->setCollisionType(WorldEntity::Kinematic);
    3128                                this->enableCollisionCallback();
    3229
    3330                                //Add Collision Shape
    3431                                SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
    35                                 collisionShape->setRadius(5.0);
     32                                collisionShape->setRadius(1.0);
    3633                                this->attachCollisionShape(collisionShape);
    3734
    3835                                //Create Bomb Model
    39 
     36                    Model* model = new Model(this->getContext());
     37                    model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
     38                    model->scale(0.7f);
     39                    this->attach(model);
    4040
    4141                        }
     
    4646        void GravityBomb::tick(float dt)
    4747        {
     48                        velocityAtLastTick_=getVelocity().length();
     49                        SUPER(GravityBomb,tick,dt);
    4850                        if(velocityAtLastTick_ < this->getVelocity().length())
    4951                        {
     52                                orxout(debug_output) << "bomb has stoped moving" <<endl;
    5053                                setVelocity(Vector3::ZERO);
    5154                                setAcceleration(Vector3::ZERO);
    5255                                velocityAtLastTick_=0;
    5356                                detonate();
     57                                orxout(debug_output) << "denoting" <<endl;
    5458                        }
    55                         velocityAtLastTick_=getVelocity().length();
     59                        else
     60                        {
     61                                velocityAtLastTick_=getVelocity().length();
     62                                orxout(debug_output)<< velocityAtLastTick_ <<endl;
     63                                orxout(debug_output) << "acceleration" << getAcceleration().length() <<endl;
     64                                destroyCheck();
     65                        }
    5666        }
    5767
    5868        bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
    5969        {
    60                 detonate();
     70                orxout(debug_output) << "collides" << endl;
    6171                processCollision(otherObject, contactPoint,cs);
     72                //detonate();
    6273                return true;
    6374        }
     
    6677        {
    6778                GravityBombField* field = new GravityBombField(this->getContext());
     79                orxout(debug_output) << "denoting" <<endl;
     80                this->destroy();
    6881        }
    6982}
Note: See TracChangeset for help on using the changeset viewer.