-
- keep_in_bounds(translation);
- shake();
-
-#if 0
- static const Vector camera_speed = Vector(300, 100);
-
- Player* player = sector->player;
- const Vector& player_pos = player->get_bbox().get_middle();
- static Vector last_player_pos = player_pos;
- static Vector camera_delta = Vector(0, 0);
-
- (void) elapsed_time;
-
- Vector player_delta_x = player_pos - last_player_pos;
- last_player_pos = player_pos;
-
- Vector camera_delta_antic = Vector(0, 0) + player_delta_x * 25;
- Vector myspeed = (camera_delta_antic - camera_delta) / elapsed_time;
- myspeed.x = clamp(-camera_speed.x, camera_speed.x, myspeed.x);
- myspeed.y = clamp(-camera_speed.y, camera_speed.y, myspeed.y);
-
- camera_delta += myspeed * elapsed_time;
-
- translation.x = camera_delta.x + player_pos.x - 0.5f * SCREEN_WIDTH;
- translation.y = camera_delta.y + player_pos.y - 0.5f * SCREEN_HEIGHT;
-
- keep_in_bounds(translation);
- shake();
-#endif
-}
-
-void
-Camera::update_scroll_normal(float elapsed_time)
-{
- if (cameraStyle == CameraStyleEXP) {
- update_scroll_normal_exp(elapsed_time);
- return;
- }
- if (cameraStyle == CameraStyleKD) {
- update_scroll_normal_kd(elapsed_time);
- return;
- }
-
- assert(sector != 0);
- Player* player = sector->player;
-
- // check that we don't have division by zero later
- if(elapsed_time < EPSILON)
- return;
-
- /****** Vertical Scrolling part ******/
- bool do_y_scrolling = true;
-
- if(player->is_dying() || sector->get_height() == 19*32)
- do_y_scrolling = false;
-
- if(do_y_scrolling) {
- // target_y is the high we target our scrolling at. This is not always the
- // high of the player, but if he is jumping upwards we should use the
- // position where he last touched the ground. (this probably needs
- // exceptions for trampolines and similar things in the future)
- float target_y;
- 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;
-
- // delta_y is the distance we'd have to travel to directly reach target_y
- float delta_y = translation.y - (target_y - SCREEN_HEIGHT*2/3);
- // speed is the speed the camera would need to reach target_y in this frame
- float speed_y = delta_y / elapsed_time;
-
- // limit the camera speed when jumping upwards
- if(player->fall_mode != Player::FALLING
- && player->fall_mode != Player::TRAMPOLINE_JUMP) {
- speed_y = clamp(speed_y, -MAX_SPEED_Y, MAX_SPEED_Y);
+ if(xmode == 4) {
+ float LEFTEND = SCREEN_WIDTH * config.edge_x;
+ float RIGHTEND = SCREEN_WIDTH * (1 - config.edge_x);
+
+ if (player_delta.x < -EPSILON) {
+ // walking left
+ lookahead_pos -= player_delta.x * config.dynamic_speed_sm;
+
+ if(lookahead_pos > RIGHTEND) {
+ lookahead_pos = RIGHTEND;
+ }
+ } else if (player_delta.x > EPSILON) {
+ // walking right
+ lookahead_pos -= player_delta.x * config.dynamic_speed_sm;
+ if(lookahead_pos < LEFTEND) {
+ lookahead_pos = LEFTEND;
+ }