---
 src/weapon/parachute.cpp |   66 +++++++---------------------------------------
 src/weapon/parachute.h   |    8 -----
 2 files changed, 10 insertions(+), 64 deletions(-)

diff --git a/src/weapon/parachute.cpp b/src/weapon/parachute.cpp
index 304fb23..2cbfe52 100644
--- a/src/weapon/parachute.cpp
+++ b/src/weapon/parachute.cpp
@@ -55,8 +55,6 @@ Parachute::Parachute() : Weapon(WEAPON_PARACHUTE, 
"parachute", new ParachuteConf
 
   m_category = MOVE;
   m_initial_nb_ammo = 2;
-  m_x_strength.x_extern = 0.0;
-  m_x_strength.changing = false;
   use_unit_on_first_shoot = false;
   img = GetResourceManager().LoadSprite(weapons_res_profile, 
"parachute_sprite");
 }
@@ -78,7 +76,6 @@ void Parachute::p_Select()
 {
   open = false;
   closing = false;
-  m_x_strength.changing = false;
   img->animation.SetShowOnFinish(SpriteAnimation::show_last_frame);
 }
 
@@ -150,9 +147,16 @@ void Parachute::Refresh()
   }
   // If parachute is open => character can move a little to the left or to the 
right
   if (open) {
-    ActiveCharacter().SetExternForce(m_x_strength.x_extern, 0.0);
-    if (m_x_strength.changing) {
-      m_x_strength.changing = false;
+    if (ActiveCharacter().IsMovingLeft(false) && 
!ActiveCharacter().IsMovingRight(false)) {
+      if(ActiveCharacter().GetDirection() == DIRECTION_RIGHT)
+        ActiveCharacter().SetDirection(DIRECTION_LEFT);
+      ActiveCharacter().SetExternForce(-cfg().force_side_displacement, 0.0);
+    }
+
+    if (ActiveCharacter().IsMovingRight(false) && 
!ActiveCharacter().IsMovingLeft(false)) {
+      if(ActiveCharacter().GetDirection() == DIRECTION_LEFT)
+        ActiveCharacter().SetDirection(DIRECTION_RIGHT);
+      ActiveCharacter().SetExternForce(cfg().force_side_displacement, 0.0);
     }
   }
 }
@@ -177,56 +181,6 @@ void Parachute::HandleKeyPressed_Shoot()
   }
 }
 
-void Parachute::HandleKeyPressed_MoveRight(bool slowly)
-{
-  if (closing) {
-    ActiveCharacter().BeginMovementRL(0);
-  }
-
-  if (open) {
-    ActiveCharacter().SetDirection(DIRECTION_RIGHT);
-    m_x_strength.x_extern = cfg().force_side_displacement;
-    m_x_strength.changing = true;
-  } else {
-    Weapon::HandleKeyPressed_MoveRight(slowly);
-  }
-}
-
-void Parachute::HandleKeyReleased_MoveRight(bool slowly)
-{
-  if (open) {
-    m_x_strength.x_extern = 0.0;
-    m_x_strength.changing = true;
-  } else {
-    Weapon::HandleKeyReleased_MoveRight(slowly);
-  }
-}
-
-void Parachute::HandleKeyPressed_MoveLeft(bool slowly)
-{
-  if (closing) {
-    ActiveCharacter().BeginMovementRL(0);
-  }
-
-  if (open) {
-    ActiveCharacter().SetDirection(DIRECTION_LEFT);
-    m_x_strength.x_extern = -cfg().force_side_displacement;
-    m_x_strength.changing = true;
-  } else {
-    Weapon::HandleKeyPressed_MoveLeft(slowly);
-  }
-}
-
-void Parachute::HandleKeyReleased_MoveLeft(bool slowly)
-{
-  if (open) {
-    m_x_strength.x_extern = 0.0;
-    m_x_strength.changing = true;
-  } else {
-    Weapon::HandleKeyReleased_MoveLeft(slowly);
-  }
-}
-
 ParachuteConfig& Parachute::cfg() {
   return static_cast<ParachuteConfig&>(*extra_params);
 }
diff --git a/src/weapon/parachute.h b/src/weapon/parachute.h
index 781f301..596aac4 100644
--- a/src/weapon/parachute.h
+++ b/src/weapon/parachute.h
@@ -35,10 +35,6 @@ class Parachute : public Weapon
     bool open;
     bool closing;
 
-    struct {
-      double x_extern;
-      bool changing;
-    } m_x_strength;
     Sprite* img;
   protected:
     void p_Select();
@@ -52,10 +48,6 @@ class Parachute : public Weapon
     bool IsInUse() const;
 
     void HandleKeyPressed_Shoot();
-    void HandleKeyPressed_MoveRight(bool slowly);
-    void HandleKeyReleased_MoveRight(bool slowly);
-    void HandleKeyPressed_MoveLeft(bool slowly);
-    void HandleKeyReleased_MoveLeft(bool slowly);
 
     void UpdateTranslationStrings();
     std::string GetWeaponWinString(const char *TeamName, uint items_count ) 
const;
-- 
1.6.0.4


_______________________________________________
Wormux-dev mailing list
Wormux-dev@gna.org
https://mail.gna.org/listinfo/wormux-dev

Répondre à