- Timestamp:
- Apr 16, 2015, 4:43:55 PM (10 years ago)
- Location:
- code/branches/weaponFS15/src/modules/weapons/projectiles
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
r10341 r10369 6 6 */ 7 7 #include "GravityBomb.h" 8 #include "graphics/Model.h" 8 9 9 10 10 11 namespace orxonox{ 11 12 RegisterClass(GravityBomb); 12 13 const float GravityBomb::INITIAL_VELOCITY = 20;14 const float GravityBomb::SLOW_DOWN_RATIO = 2;15 13 16 14 GravityBomb::GravityBomb(Context* context): … … 24 22 if (GameMode::isMaster()) 25 23 { 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); 31 28 this->enableCollisionCallback(); 32 29 33 30 //Add Collision Shape 34 31 SphereCollisionShape* collisionShape = new SphereCollisionShape(context); 35 collisionShape->setRadius( 5.0);32 collisionShape->setRadius(1.0); 36 33 this->attachCollisionShape(collisionShape); 37 34 38 35 //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); 40 40 41 41 } … … 46 46 void GravityBomb::tick(float dt) 47 47 { 48 velocityAtLastTick_=getVelocity().length(); 49 SUPER(GravityBomb,tick,dt); 48 50 if(velocityAtLastTick_ < this->getVelocity().length()) 49 51 { 52 orxout(debug_output) << "bomb has stoped moving" <<endl; 50 53 setVelocity(Vector3::ZERO); 51 54 setAcceleration(Vector3::ZERO); 52 55 velocityAtLastTick_=0; 53 56 detonate(); 57 orxout(debug_output) << "denoting" <<endl; 54 58 } 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 } 56 66 } 57 67 58 68 bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 59 69 { 60 detonate();70 orxout(debug_output) << "collides" << endl; 61 71 processCollision(otherObject, contactPoint,cs); 72 //detonate(); 62 73 return true; 63 74 } … … 66 77 { 67 78 GravityBombField* field = new GravityBombField(this->getContext()); 79 orxout(debug_output) << "denoting" <<endl; 80 this->destroy(); 68 81 } 69 82 } -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
r10341 r10369 66 66 67 67 private: 68 static const float INITIAL_VELOCITY;69 static const float SLOW_DOWN_RATIO;70 68 71 69 float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it. -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
r10341 r10369 11 11 RegisterClass(GravityBombField); 12 12 13 const float GravityBombField::FORCE_FIELD_LIFETIME = 10;14 const float GravityBombField::FORCE_SPHERE_START_RADIUS = 50;15 const float GravityBombField::FORCE_SPHERE_START_STRENGTH = - 300;13 const float GravityBombField::FORCE_FIELD_LIFETIME = 5; 14 const float GravityBombField::FORCE_SPHERE_START_RADIUS = 100; 15 const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -1000; 16 16 17 17 GravityBombField::GravityBombField(Context* context) : ForceField(context) 18 18 { 19 RegisterObject(GravityBombField); 19 20 lifetime_=FORCE_FIELD_LIFETIME; 20 21 setVelocity(FORCE_SPHERE_START_STRENGTH); … … 27 28 void GravityBombField::tick(float dt) 28 29 { 30 SUPER(GravityBombField,tick,dt); 29 31 lifetime_-=dt; 30 32 if(lifetime_ < 0) … … 37 39 { 38 40 //Animation 39 //SUPER(GravityBombField,destroy);41 ForceField::destroy(); 40 42 } 41 43
Note: See TracChangeset
for help on using the changeset viewer.