X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmainloop.cpp;h=72b3eed93b9d72e268741c1853a06f57e78823bd;hb=f7659d1e6e1268e6fec002e806a8a469408aa335;hp=fb45247c7cfcc73c4633e743e35b07dbdea83059;hpb=d963f8dc3d2c4e432d3eeecd15351169e10243da;p=supertux.git diff --git a/src/mainloop.cpp b/src/mainloop.cpp index fb45247c7..72b3eed93 100644 --- a/src/mainloop.cpp +++ b/src/mainloop.cpp @@ -114,23 +114,22 @@ MainLoop::draw_fps(DrawingContext& context, float fps_fps) char str[60]; snprintf(str, sizeof(str), "%3.1f", fps_fps); const char* fpstext = "FPS"; - context.draw_text(white_text, fpstext, Vector(SCREEN_WIDTH - white_text->get_text_width(fpstext) - gold_text->get_text_width(" 99999") - BORDER_X, BORDER_Y + 20), LEFT_ALLIGN, LAYER_FOREGROUND1); - context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), RIGHT_ALLIGN, LAYER_FOREGROUND1); + context.draw_text(white_text, fpstext, Vector(SCREEN_WIDTH - white_text->get_text_width(fpstext) - gold_text->get_text_width(" 99999") - BORDER_X, BORDER_Y + 20), LEFT_ALLIGN, LAYER_HUD); + context.draw_text(gold_text, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), RIGHT_ALLIGN, LAYER_HUD); } void MainLoop::run() { - DrawingContext context; - + DrawingContext context; + unsigned int frame_count = 0; - unsigned int rand_prints = 0; float fps_fps = 0; Uint32 fps_ticks = SDL_GetTicks(); Uint32 fps_nextframe_ticks = SDL_GetTicks(); Uint32 ticks; bool skipdraw = false; - + running = true; while(running) { while( (next_screen.get() != NULL || nextpop == true) && @@ -150,7 +149,7 @@ MainLoop::run() if(nextpush && current_screen.get() != NULL) { screen_stack.push_back(current_screen.release()); } - + nextpush = false; nextpop = false; speed = 1.0; @@ -164,7 +163,7 @@ MainLoop::run() if(!running || current_screen.get() == NULL) break; - + float elapsed_time = 1.0 / LOGICAL_FPS; ticks = SDL_GetTicks(); if(ticks > fps_nextframe_ticks) { @@ -207,7 +206,7 @@ MainLoop::run() if(config->show_fps) { ++frame_count; - + if(SDL_GetTicks() - fps_ticks >= 500) { fps_fps = (float) frame_count / .5; @@ -220,14 +219,14 @@ MainLoop::run() real_time += elapsed_time; elapsed_time *= speed; game_time += elapsed_time; - + Scripting::update_debugger(); Scripting::TimeScheduler::instance->update(game_time); current_screen->update(elapsed_time); if(screen_fade.get() != NULL) screen_fade->update(elapsed_time); Console::instance->update(elapsed_time); - + main_controller->update(); SDL_Event event; while(SDL_PollEvent(&event)) { @@ -239,11 +238,7 @@ MainLoop::run() } sound_manager->update(); - - // insert calls for debug (there are few rand calls otherwise) - if (0 && rand_prints++ % 20 == 0) - log_info << "== periodic rand() call " << systemRandom.rand() << - " at frame " << rand_prints << "==" <