Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17807/src
Modified Files:
world.cpp world.h
Log Message:
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); »
Index: world.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/world.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- world.h 4 May 2004 13:59:00 -0000 1.35
+++ world.h 4 May 2004 15:38:58 -0000 1.36
@@ -45,7 +45,6 @@
Player tux;
Timer scrolling_timer;
- float moved_scroll_x;
int distro_counter;
bool counting_distros;
@@ -79,7 +78,7 @@
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();
Index: world.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- world.cpp 4 May 2004 14:41:14 -0000 1.56
+++ world.cpp 4 May 2004 15:38:58 -0000 1.57
@@ -261,7 +261,7 @@
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 @@
#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 @@
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))
|