From: Matthias Braun Date: Sat, 3 Mar 2007 20:21:37 +0000 (+0000) Subject: fix clamping code, enable it in camera.cfg again X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=5ccd869de67b23deb72a52c2233921343d996f7b;p=supertux.git fix clamping code, enable it in camera.cfg again SVN-Revision: 4918 --- diff --git a/data/camera.cfg b/data/camera.cfg index 02202948e..5dfc76c75 100644 --- a/data/camera.cfg +++ b/data/camera.cfg @@ -19,17 +19,15 @@ ; Speed is limited to these for the Yoshi cam (max-speed-x 80) - (max-speed-y 140) + (max-speed-y 80) ; Used in YI camera to adjust to max_speed relatively to player speed (dynamic-max-speed-x 1.0) ; Make sure tux never leaves the clamp area on screen (works for all ; cameras, can be disabled by setting it to 0) - ;(clamp-x .1666) - ;(clamp-y .1666) - (clamp-x 0) - (clamp-y 0) + (clamp-x 0.1666) + (clamp-y 0.1666) ; Keep tux here when he runs in YI mode (edge-x 0.28) diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 2f9f4994e..0e66cbc8b 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -338,8 +338,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 +347,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 +397,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; } } @@ -411,9 +410,9 @@ Camera::update_scroll_normal(float elapsed_time) // 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 +440,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 +449,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);