[Super-tux-commit] supertux/src world.cpp,1.106,1.107
Brought to you by:
wkendrick
From: Matze B. <mat...@us...> - 2004-05-20 23:58:42
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10770/src Modified Files: world.cpp Log Message: fix jerky scrolling Index: world.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/world.cpp,v retrieving revision 1.106 retrieving revision 1.107 diff -u -d -r1.106 -r1.107 --- world.cpp 20 May 2004 23:34:53 -0000 1.106 +++ world.cpp 20 May 2004 23:58:31 -0000 1.107 @@ -218,16 +218,16 @@ } void -World::action(double frame_ratio) +World::action(float elapsed_time) { - tux->check_bounds(level->back_scrolling, (bool)level->hor_autoscroll_speed); - scrolling(frame_ratio); - /* update objects (don't use iterators here, because the list might change * during the iteration) */ for(size_t i = 0; i < gameobjects.size(); ++i) - gameobjects[i]->action(frame_ratio); + gameobjects[i]->action(elapsed_time); + + tux->check_bounds(level->back_scrolling, (bool)level->hor_autoscroll_speed); + scrolling(elapsed_time); /* Handle all possible collisions. */ collision_handler(); @@ -282,7 +282,7 @@ #define CHANGE_DIR_SCROLL_SPEED 2000 /* This functions takes cares of the scrolling */ -void World::scrolling(double frame_ratio) +void World::scrolling(float elapsed_time) { /* Y-axis scrolling */ @@ -307,7 +307,7 @@ /* Auto scrolling */ if(level->hor_autoscroll_speed) { - scroll_x += level->hor_autoscroll_speed * frame_ratio; + scroll_x += level->hor_autoscroll_speed * elapsed_time; return; } @@ -354,12 +354,13 @@ constant2 = 0.; } - float number = 2.5/(frame_ratio * CHANGE_DIR_SCROLL_SPEED/1000)*exp((CHANGE_DIR_SCROLL_SPEED-scrolling_timer.get_left())/1400.); + float number = 2.5/(elapsed_time * CHANGE_DIR_SCROLL_SPEED/1000)*exp((CHANGE_DIR_SCROLL_SPEED-scrolling_timer.get_left())/1400.); if(left) number *= -1.; scroll_x += number - + constant1 * tux->physic.get_velocity_x() * frame_ratio - + constant2 * tux->physic.get_acceleration_x() * frame_ratio * frame_ratio; + + constant1 * tux->physic.get_velocity_x() * elapsed_time + + constant2 * tux->physic.get_acceleration_x() * elapsed_time * + elapsed_time; if ((right && final_scroll_x - scroll_x < 0) || (left && final_scroll_x - scroll_x > 0)) scroll_x = final_scroll_x; |