Rope works
authorekku
Sat, 06 Dec 2008 21:12:30 +0000
changeset 229 355e46effa41
parent 228 dbc1bb7a98b5
child 230 78cf0cd69af4
Rope works
src/Input.cc
src/Input.hh
src/PhysicsObject.cc
src/Player.cc
src/Rope.cc
--- a/src/Input.cc	Sat Dec 06 21:02:35 2008 +0000
+++ b/src/Input.cc	Sat Dec 06 21:12:30 2008 +0000
@@ -13,6 +13,7 @@
     {   CL_KEY_F,       INPUT_SHOOT         },
     {   CL_KEY_D,       INPUT_CHANGE        },
     {   CL_KEY_R,       INPUT_ROPE          },
+    {   CL_KEY_RSHIFT,  INPUT_UNROPE        },
     {   0,              (_PlayerInput) 0    }
 };
 
--- a/src/Input.hh	Sat Dec 06 21:02:35 2008 +0000
+++ b/src/Input.hh	Sat Dec 06 21:12:30 2008 +0000
@@ -17,7 +17,8 @@
     INPUT_DIG           = 0x0020,
     INPUT_SHOOT         = 0x0040,
     INPUT_CHANGE        = 0x0080,
-    INPUT_ROPE          = 0x0100
+    INPUT_ROPE          = 0x0100,
+    INPUT_UNROPE        = 0x0200
 };
 
 typedef uint16_t PlayerInput;
--- a/src/PhysicsObject.cc	Sat Dec 06 21:02:35 2008 +0000
+++ b/src/PhysicsObject.cc	Sat Dec 06 21:12:30 2008 +0000
@@ -5,7 +5,8 @@
 #include <cmath>
 
 PhysicsObject::PhysicsObject (PhysicsWorld &world, float mass, Vector position, Vector velocity, bool enabled) :
-    world(world), position(position), velocity(velocity), mass(mass), inAir(true), aim(0), facingRight(true), alive(false), shouldDelete(false)
+    world(world), position(position), velocity(velocity), mass(mass), inAir(true), aim(0), facingRight(true), 
+    alive(false), shouldDelete(false), pivot(NULL)
 {  
     if (enabled)
         enable();  
--- a/src/Player.cc	Sat Dec 06 21:02:35 2008 +0000
+++ b/src/Player.cc	Sat Dec 06 21:12:30 2008 +0000
@@ -157,6 +157,9 @@
     if (input & INPUT_ROPE)
         rope.shoot();
 
+    if (input & INPUT_UNROPE)
+        rope.release();
+
     // XXX: how should this be written?
     if (move_force.x != 0) 
         animation_step = (animation_step + 1) % img_num_step;
--- a/src/Rope.cc	Sat Dec 06 21:02:35 2008 +0000
+++ b/src/Rope.cc	Sat Dec 06 21:12:30 2008 +0000
@@ -38,6 +38,10 @@
 }
 
 void Rope::release (void) {
+
+    if (this->rs == FLYING)
+        disable();
+
     // TODO make it fly first and fold only 
     // after it's close to the player
     this->rs = FOLDED;
@@ -52,7 +56,7 @@
 
 float Rope::getPivotForce (PhysicsObject *bob) {
     if ( (this->position - pl.getPosition()).length() >= this->length)
-        return 2000;
+        return 3500;
     else
         return 0;
 }