Rope length changing possible
authorekku
Sat, 06 Dec 2008 21:39:52 +0000
changeset 231 5085764e1dbb
parent 230 78cf0cd69af4
child 232 59f014d22a38
Rope length changing possible
src/Player.cc
src/Rope.cc
src/Rope.hh
--- a/src/Player.cc	Sat Dec 06 21:35:36 2008 +0000
+++ b/src/Player.cc	Sat Dec 06 21:39:52 2008 +0000
@@ -45,7 +45,7 @@
 void Player::handleDig (Vector position, float radius) {
     Vector unitVectorAim = facingRight ? Vector(std::cos(aim), -std::sin(aim)) : 
             Vector(-std::cos(aim), -std::sin(aim));
-    float shotspeed = 0*PHYSICS_TICK_MS;
+    float shotspeed = 1;//0*PHYSICS_TICK_MS;
     Vector shotVelocity = unitVectorAim*shotspeed;
     new Projectile(this->state, this->position, shotVelocity, false, radius, 1);
 
@@ -160,6 +160,12 @@
     if (input & INPUT_UNROPE)
         rope.release();
 
+    if (input & INPUT_ROPE_UP)
+        rope.changeLength(true);
+
+    if (input & INPUT_ROPE_DOWN)
+        rope.changeLength(false);
+
     // 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:35:36 2008 +0000
+++ b/src/Rope.cc	Sat Dec 06 21:39:52 2008 +0000
@@ -50,6 +50,12 @@
     pl.setPivot(NULL);
 }
 
+void Rope::changeLength (bool shorten) {
+    this->length += shorten ? -5 : 5;
+    if (this->length < 0)
+        this->length = 0;
+}
+
 RopeState Rope::getState (void) {
     return this->rs;
 }
--- a/src/Rope.hh	Sat Dec 06 21:35:36 2008 +0000
+++ b/src/Rope.hh	Sat Dec 06 21:39:52 2008 +0000
@@ -26,6 +26,7 @@
 
     void shoot (void);
     void release (void);
+    void changeLength (bool shorten);
     RopeState getState (void);
     virtual void draw(CL_GraphicContext *gc) const;
 };