X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fgameloop.cpp;h=5e860225f50e6ff5bea266ae5d3bfc55209d9e8f;hb=820473dd8331f9c8949f0d492162fa9d1860ca90;hp=d0368f01630d4f5145efbc68a693debda26caa41;hpb=b56d18cd12b1892a7588b1fe620b1df26f7e7d4f;p=supertux.git diff --git a/src/gameloop.cpp b/src/gameloop.cpp index d0368f016..5e860225f 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -10,6 +10,7 @@ April 11, 2000 - March 15, 2004 */ +#include #include #include #include @@ -62,6 +63,8 @@ GameSession::restart_level() fps_timer.init(true); frame_timer.init(true); + delete world; + if (st_gl_mode == ST_GL_LOAD_LEVEL_FILE) { world = new World(subset); @@ -316,7 +319,8 @@ GameSession::check_end_conditions() // Check End conditions if (tux->is_dead()) { - + player_status.lives -= 1; + if (player_status.lives < 0) { // No more lives!? if(st_gl_mode != ST_GL_TEST) @@ -324,8 +328,10 @@ GameSession::check_end_conditions() if(st_gl_mode != ST_GL_TEST) { - if (player_status.score > hs_score) - save_hs(player_status.score); + // FIXME: highscore soving doesn't make sense in its + // current form + //if (player_status.score > hs_score) + //save_hs(player_status.score); } exit_status = GAME_OVER; @@ -345,10 +351,7 @@ GameSession::action(double frame_ratio) if (exit_status == NONE) { - Player* tux = world->get_tux(); - // Update Tux and the World - tux->action(frame_ratio); world->action(frame_ratio); } } @@ -410,12 +413,11 @@ GameSession::run() draw(); + float overlap = 0.0f; while (exit_status == NONE) { /* Calculate the movement-factor */ double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE); - if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */ - frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85; if(!frame_timer.check()) { @@ -437,14 +439,7 @@ GameSession::run() case 2: st_pause_ticks_stop(); break; - case 3: - // FIXME: - //update_load_save_game_menu(save_game_menu); - break; - case 4: - update_load_save_game_menu(load_game_menu); - break; - case 7: + case 5: st_pause_ticks_stop(); exit_status = LEVEL_ABORT; break; @@ -463,7 +458,15 @@ GameSession::run() // Handle actions: if(!game_pause && !show_menu) { - action(frame_ratio); + frame_ratio *= game_speed; + frame_ratio += overlap; + while (frame_ratio > 0) + { + action(1.0f); + frame_ratio -= 1.0f; + } + overlap = frame_ratio; + if (exit_status != NONE) return exit_status; }