diff --git a/main.c b/main.c index f4437b0..fa5371e 100644 --- a/main.c +++ b/main.c @@ -33,8 +33,10 @@ GameState gameState = MainMenu; Scenery scenery; int main(int argc, char * args[]){ - // printf("Spielbereiche\n\t- 1: Hauptmen"ue "\n\t- 2: Spiel\n\t- 3: Level Select\n\t- 4: Settings\n\t- 5: Highscores\n"); - // GAME_ChangeState(readIntFromIO("W"ae "hle einen Spielbereich aus, den du testen m"oe "chtest:", "Fehlerhafte Eingabe!\n", "%d ist kein g"ue "ltiger Spielbereich!\n", 1, 5)); + Uint32 fps_lasttime = SDL_GetTicks(); // the last recorded time. + Uint32 fps_current; // the current FPS. + Uint32 fps_frames = 0; // frames passed since the last recorded fps. + INITIALIZE(); while (running) { // Gameloop HandleSDLEvents(); @@ -60,6 +62,13 @@ int main(int argc, char * args[]){ break; } SDL_RenderPresent(renderer); + fps_frames++; + if (fps_lasttime < SDL_GetTicks() - 1000) { + fps_lasttime = SDL_GetTicks(); + fps_current = fps_frames; + fps_frames = 0; + printf("Frames/s: %u\n", fps_current); + } } QUIT(); return 0; @@ -197,28 +206,3 @@ void QUIT(){ printf("Quitting SDL finished!\n"); printf("De-initializing finished!\n"); } /* QUIT */ - -int readIntFromIO(char * m1, char * m2, char * m3, int min, int max){ - int nitems, num; - - while (1) { - while (1) { - printf(m1); - nitems = scanf("%d", &num); - if (nitems == 0) { - printf(m2); - fflush(stdin); - continue; - } else { - break; - } - } - if ((num < min) || (num > max)) { - printf(m3, num); - } else { - break; - } - } - fflush(stdin); - return(num); -} /* readIntFromIO */ diff --git a/main.h b/main.h index c2b62b9..b1c54b0 100644 --- a/main.h +++ b/main.h @@ -36,7 +36,6 @@ void windowChanged(SDL_WindowEvent b); void DrawBackground(SDL_Renderer * renderer); void INITIALIZE(); void QUIT(); -int readIntFromIO(char * m1, char * m2, char * m3, int min, int max); // End Prototypes #endif // __main_h__