B91: Tux now guesses direction to walk in during an end sequence.
[supertux.git] / src / object / endsequence.cpp
index dac0b8f..23c530f 100644 (file)
@@ -51,7 +51,7 @@ void
 EndSequence::update(float elapsed_time)
 {
   if (!isrunning) return;
-  running(elapsed_time);    
+  running(elapsed_time);
 }
 
 void
@@ -60,17 +60,19 @@ EndSequence::draw(DrawingContext& /*context*/)
 }
 
 void
-EndSequence::start()
+EndSequence::start(Direction dir)
 {
   if (isrunning) return;
   isrunning = true;
   isdone = false;
-  
+
   Player& tux = *Sector::current()->player;
   end_sequence_controller = new CodeController();
   tux.set_controller(end_sequence_controller);
   tux.set_speedlimit(230); //MAX_WALK_XM
 
+  walk_dir = dir;
+
   starting();
 }
 
@@ -100,12 +102,12 @@ EndSequence::is_done()
 {
   return isdone;
 }
-    
+
 void
 EndSequence::starting()
 {
   last_x_pos = -1;
-  endsequence_timer.start(7.3);
+  endsequence_timer.start(7.3f);
 }
 
 void
@@ -114,7 +116,7 @@ EndSequence::running(float /*elapsed_time*/)
   Player& tux = *Sector::current()->player;
 
   if (tux_may_walk) {
-    end_sequence_controller->press(Controller::RIGHT);
+    end_sequence_controller->press((walk_dir == RIGHT) ? Controller::RIGHT : Controller::LEFT);
     if (int(last_x_pos) == int(tux.get_pos().x)) {
       end_sequence_controller->press(Controller::JUMP);
     }
@@ -129,4 +131,3 @@ void
 EndSequence::stopping()
 {
 }
-