From 0fac295c23be26411ba3695f80dfcd7d7e3eb770 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Tue, 4 May 2004 15:38:58 +0000 Subject: [PATCH] =?utf8?q?Fixed=20srolling=20camera=20move.=20Silly=20me,?= =?utf8?q?=20I=20forgot=20about=20the=20frame=20rates.=20It=20still=20does?= =?utf8?q?n't=20work,=20since=20the=20frame=5Fratio=20variable=20is=20not?= =?utf8?q?=20calculated...=20It=20has=20allways=20the=20same=20value.=20Is?= =?utf8?q?=20this=20some=20workaround=3F=20=EF=BF=BD=20=20action(1.0f);=20?= =?utf8?q?=20=EF=BF=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit SVN-Revision: 972 --- src/world.cpp | 13 ++++--------- src/world.h | 3 +-- 2 files changed, 5 insertions(+), 11 deletions(-) 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(); -- 2.11.0