at the left or right end, it's obvious which dir we will go next
authorMatthias Braun <matze@braunis.de>
Sat, 3 Mar 2007 21:09:25 +0000 (21:09 +0000)
committerMatthias Braun <matze@braunis.de>
Sat, 3 Mar 2007 21:09:25 +0000 (21:09 +0000)
SVN-Revision: 4921

src/object/camera.cpp

index a0f6bc9..8ad604f 100644 (file)
@@ -378,14 +378,21 @@ Camera::update_scroll_normal(float elapsed_time)
     float LEFTEND = SCREEN_WIDTH * config.sensitive_x;
     float RIGHTEND = SCREEN_WIDTH * (1-config.sensitive_x);
 
-    /* if we're undecided then look if we crossed the left or right "sensitive"
-     * area */
     if(lookahead_mode == LOOKAHEAD_NONE) {
+      /* if we're undecided then look if we crossed the left or right
+       * "sensitive" area */
       if(player_pos.x < translation.x + LEFTEND) {
         lookahead_mode = LOOKAHEAD_LEFT;
       } else if(player_pos.x > translation.x + RIGHTEND) {
         lookahead_mode = LOOKAHEAD_RIGHT;
       }
+      /* at the ends of a level it's obvious which way we will go */
+      if(player_pos.x < SCREEN_WIDTH*0.5) {
+        lookahead_mode = LOOKAHEAD_RIGHT;
+      } else if(player_pos.x >= sector->get_width() - SCREEN_WIDTH*0.5) {
+        lookahead_mode = LOOKAHEAD_LEFT;
+      }
+
       changetime = -1;
     } else if(lookahead_mode != walkDirection) {
       /* player changed direction while camera was scrolling...