---
 src/weapon/supertux.cpp |   43 +++++++++++++++++++++++++------------------
 src/weapon/supertux.h   |    8 ++++++++
 2 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/weapon/supertux.cpp b/src/weapon/supertux.cpp
index a811c08..948f681 100644
--- a/src/weapon/supertux.cpp
+++ b/src/weapon/supertux.cpp
@@ -238,6 +238,12 @@ bool TuxLauncher::p_Shoot ()
 
   current_tux = static_cast<SuperTux *>(projectile);
   tux_death_time = 0;
+  move_left_pressed = false;
+  move_right_pressed = false;
+  ActiveCharacter().StopMovingLeft(true);
+  ActiveCharacter().StopMovingLeft(false);
+  ActiveCharacter().StopMovingRight(true);
+  ActiveCharacter().StopMovingRight(false);
   bool r = WeaponLauncher::p_Shoot();
 
   return r;
@@ -245,12 +251,17 @@ bool TuxLauncher::p_Shoot ()
 
 void TuxLauncher::Refresh()
 {
-  if (current_tux)
-    return;
-
-  if (tux_death_time && tux_death_time + 2000 < Time::GetInstance()->Read()) {
-    UseAmmoUnit();
-    tux_death_time = 0;
+  if (current_tux) {
+    if (move_left_pressed && !move_right_pressed) {
+      current_tux->turn_left();
+    } else if (move_right_pressed && !move_left_pressed) {
+      current_tux->turn_right();
+    }
+  } else {
+    if (tux_death_time && tux_death_time + 2000 < Time::GetInstance()->Read()) 
{
+      UseAmmoUnit();
+      tux_death_time = 0;
+    }
   }
 }
 
@@ -289,22 +300,20 @@ void TuxLauncher::StopShooting()
 // Move right
 void TuxLauncher::HandleKeyPressed_MoveRight(bool slowly)
 {
-  if (current_tux)
-    current_tux->turn_right();
-  else if (!tux_death_time)
+  StartMovingRightForAllPlayers();
+  if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyPressed_MoveRight(slowly);
 }
 
 void TuxLauncher::HandleKeyRefreshed_MoveRight(bool slowly)
 {
-  if (current_tux)
-    current_tux->turn_right();
-  else if (!tux_death_time)
+  if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyRefreshed_MoveRight(slowly);
 }
 
 void TuxLauncher::HandleKeyReleased_MoveRight(bool slowly)
 {
+  StopMovingRightForAllPlayers();
   if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyReleased_MoveRight(slowly);
 }
@@ -312,22 +321,20 @@ void TuxLauncher::HandleKeyReleased_MoveRight(bool slowly)
 // Move left
 void TuxLauncher::HandleKeyPressed_MoveLeft(bool slowly)
 {
-  if (current_tux)
-    current_tux->turn_left();
-  else if (!tux_death_time)
+  StartMovingLeftForAllPlayers();
+  if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyPressed_MoveLeft(slowly);
 }
 
 void TuxLauncher::HandleKeyRefreshed_MoveLeft(bool slowly)
 {
-  if (current_tux)
-    current_tux->turn_left();
-  else if (!tux_death_time)
+  if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyRefreshed_MoveLeft(slowly);
 }
 
 void TuxLauncher::HandleKeyReleased_MoveLeft(bool slowly)
 {
+  StopMovingLeftForAllPlayers();
   if (!current_tux && !tux_death_time)
     ActiveCharacter().HandleKeyReleased_MoveLeft(slowly);
 }
diff --git a/src/weapon/supertux.h b/src/weapon/supertux.h
index b90e504..a1da831 100644
--- a/src/weapon/supertux.h
+++ b/src/weapon/supertux.h
@@ -34,6 +34,8 @@ class TuxLauncher : public WeaponLauncher
 private:
   SuperTux * current_tux;
   uint tux_death_time;
+  bool move_left_pressed;
+  bool move_right_pressed;
 
 public:
   TuxLauncher();
@@ -44,6 +46,12 @@ public:
 
   virtual void SignalEndOfProjectile();
 
+  virtual void StartMovingLeft() {move_left_pressed = true;};
+  virtual void StopMovingLeft() {move_left_pressed = false;};
+
+  virtual void StartMovingRight() {move_right_pressed = true;};
+  virtual void StopMovingRight() {move_right_pressed = false;};
+
   void StartShooting();
   void StopShooting();
 
-- 
1.6.0.4


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

Répondre à