more work on the camera
[supertux.git] / src / object / camera.cpp
index 0232d1f..a0f6bc9 100644 (file)
@@ -315,10 +315,14 @@ Camera::update_scroll_normal(float elapsed_time)
     // position where he last touched the ground. (this probably needs
     // exceptions for trampolines and similar things in the future)
     float target_y;
+#if 0
     if(player->fall_mode == Player::JUMPING)
       target_y = player->last_ground_y + player->get_bbox().get_height();
     else
       target_y = player->get_bbox().p2.y;
+#endif
+    target_y = player->last_ground_y;
+
     target_y -= SCREEN_HEIGHT * config.target_y;
 
     // delta_y is the distance we'd have to travel to directly reach target_y
@@ -338,8 +342,8 @@ Camera::update_scroll_normal(float elapsed_time)
   if(ymode == 3) {
     float halfsize = config.kirby_rectsize_y * 0.5f;
     translation.y = clamp(translation.y,
-        player_pos.y - SCREEN_HEIGHT * (0.5f - halfsize),
-        player_pos.y - SCREEN_HEIGHT * (0.5f + halfsize));
+        player_pos.y - SCREEN_HEIGHT * (0.5f + halfsize),
+        player_pos.y - SCREEN_HEIGHT * (0.5f - halfsize));
   }
   if(ymode == 4) {
     // TODO...
@@ -347,8 +351,8 @@ Camera::update_scroll_normal(float elapsed_time)
 
   if(ymode != 0 && config.clamp_y > 0) {
     translation.y = clamp(translation.y,
-        player_pos.y - SCREEN_HEIGHT * config.clamp_y,
-        player_pos.y - SCREEN_HEIGHT * (1-config.clamp_y));
+        player_pos.y - SCREEN_HEIGHT * (1-config.clamp_y),
+        player_pos.y - SCREEN_HEIGHT * config.clamp_y);
   }
 
   /****** Horizontal scrolling part *******/
@@ -397,7 +401,6 @@ Camera::update_scroll_normal(float elapsed_time)
                   player_pos.x < translation.x + LEFTEND) {
           lookahead_mode = LOOKAHEAD_LEFT;
         } else {
-          printf("abortscroll\n");
           lookahead_mode = LOOKAHEAD_NONE;
         }
       }
@@ -406,14 +409,14 @@ Camera::update_scroll_normal(float elapsed_time)
     }
 
     LEFTEND = SCREEN_WIDTH * config.edge_x;
-    RIGHTEND = SCREEN_HEIGHT * (1-config.edge_x);
+    RIGHTEND = SCREEN_WIDTH * (1-config.edge_x);
 
     // calculate our scroll target depending on scroll mode
     float target_x;
     if(lookahead_mode == LOOKAHEAD_LEFT)
-      target_x = player->get_bbox().get_middle().x - RIGHTEND;
+      target_x = player_pos.x - RIGHTEND;
     else if(lookahead_mode == LOOKAHEAD_RIGHT)
-      target_x = player->get_bbox().get_middle().x - LEFTEND;
+      target_x = player_pos.x - LEFTEND;
     else
       target_x = translation.x;
 
@@ -441,8 +444,8 @@ Camera::update_scroll_normal(float elapsed_time)
   if(config.xmode == 3) {
     float halfsize = config.kirby_rectsize_x * 0.5f;
     translation.x = clamp(translation.x,
-        player_pos.x - SCREEN_WIDTH * (0.5f - halfsize),
-        player_pos.x - SCREEN_WIDTH * (0.5f + halfsize));
+        player_pos.x - SCREEN_WIDTH * (0.5f + halfsize),
+        player_pos.x - SCREEN_WIDTH * (0.5f - halfsize));
   }
   if(config.xmode == 4) {
     // TODO...
@@ -450,8 +453,8 @@ Camera::update_scroll_normal(float elapsed_time)
 
   if(config.xmode != 0 && config.clamp_x > 0) {
     translation.x = clamp(translation.x,
-        player_pos.x - SCREEN_WIDTH * config.clamp_x,
-        player_pos.x - SCREEN_WIDTH * (1-config.clamp_x));
+        player_pos.x - SCREEN_WIDTH * (1-config.clamp_x),
+        player_pos.x - SCREEN_WIDTH * config.clamp_x);
   }
 
   keep_in_bounds(translation);