From: Ricardo Cruz Date: Tue, 4 May 2004 15:38:58 +0000 (+0000) Subject: Fixed srolling camera move. Silly me, I forgot about the frame rates. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0fac295c23be26411ba3695f80dfcd7d7e3eb770;p=supertux.git Fixed srolling camera move. Silly me, I forgot about the frame rates. It still doesn't work, since the frame_ratio variable is not calculated... It has allways the same value. Is this some workaround? � action(1.0f); � SVN-Revision: 972 --- diff --git a/src/world.cpp b/src/world.cpp index 28c6a1b6d..54051f65a 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -261,7 +261,7 @@ void World::action(double frame_ratio) { tux.action(frame_ratio); - scrolling(); + scrolling(frame_ratio); /* Handle bouncy distros: */ for (unsigned int i = 0; i < bouncy_distros.size(); i++) @@ -316,7 +316,7 @@ World::action(double frame_ratio) #define CHANGE_DIR_SCROLL_SPEED 2000 /* This functions takes cares of the scrolling */ -void World::scrolling() +void World::scrolling(double frame_ratio) { int tux_pos_x = (int)(tux.base.x + (tux.base.width/2)); @@ -330,17 +330,12 @@ void World::scrolling() final_scroll_x = tux_pos_x - (screen->w - X_SPACE); else// if (tux.dir == LEFT)// && ) final_scroll_x = tux_pos_x - X_SPACE; - - if(moved_scroll_x == 0) - moved_scroll_x = scroll_x; - - scroll_x += (final_scroll_x - scroll_x) / (CHANGE_DIR_SCROLL_SPEED); +printf("%f\n", frame_ratio); + scroll_x += ((final_scroll_x - scroll_x) / (CHANGE_DIR_SCROLL_SPEED)) * frame_ratio; } else { - moved_scroll_x = 0; - if (tux.dir == RIGHT && scroll_x < tux_pos_x - (screen->w - X_SPACE)) scroll_x = tux_pos_x - (screen->w - X_SPACE); else if (tux.dir == LEFT && scroll_x > tux_pos_x - X_SPACE && (level->back_scrolling || debug_mode)) diff --git a/src/world.h b/src/world.h index c8716888a..1496aa8b5 100644 --- a/src/world.h +++ b/src/world.h @@ -45,7 +45,6 @@ private: Player tux; Timer scrolling_timer; - float moved_scroll_x; int distro_counter; bool counting_distros; @@ -79,7 +78,7 @@ public: void draw(); void action(double frame_ratio); - void scrolling(); // camera scrolling + void scrolling(double frame_ratio); // camera scrolling void play_music(int musictype); int get_music_type();