diff --git a/travail_de_groupe/jeu_appren_par_renfo/Res/Roboto-Black.ttf b/travail_de_groupe/jeu_appren_par_renfo/Res/Roboto-Black.ttf new file mode 100644 index 0000000000000000000000000000000000000000..86ec2b29ba56a3d6c45f1a8584ff3780fa70c60e Binary files /dev/null and b/travail_de_groupe/jeu_appren_par_renfo/Res/Roboto-Black.ttf differ diff --git a/travail_de_groupe/jeu_appren_par_renfo/Res/crowd.png b/travail_de_groupe/jeu_appren_par_renfo/Res/crowd.png index 67217ec17e065ff758b694e518aea00558e7aae5..5fdf319af7f2949b5140ee9ddb7af70a0bb6c411 100755 Binary files a/travail_de_groupe/jeu_appren_par_renfo/Res/crowd.png and b/travail_de_groupe/jeu_appren_par_renfo/Res/crowd.png differ diff --git a/travail_de_groupe/jeu_appren_par_renfo/src/render.c b/travail_de_groupe/jeu_appren_par_renfo/src/render.c index 90bd7dd8afd7a0501d246e152732c7e04135b275..3a271bdfa4fb593bdf21cdcc0347128aacb88e0e 100644 --- a/travail_de_groupe/jeu_appren_par_renfo/src/render.c +++ b/travail_de_groupe/jeu_appren_par_renfo/src/render.c @@ -17,6 +17,8 @@ SDL_Texture * crowdTexture; int ** rays; int raysListLength = 0; +float fps; + SDL_Texture * loadTexture(char * path) { SDL_Surface * surface = IMG_Load(path); SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface); @@ -115,6 +117,7 @@ void drawRayColumn(float ra, float distT, int r, int isTransparent, int directio } else { + destRect.x += + 64 * (SDL_GetTicks()/400 % 4); if (direction){ SDL_RenderCopy(renderer, crowdTexture, &destRect, &rect); //SDL_SetRenderDrawColor(renderer, 255 * (1 - isTransparent), 255, 0, 255 * (1 - isTransparent)); @@ -381,11 +384,31 @@ void drawMap2D(int map[][MAP_WIDTH]){ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); } +void drawString(char *str, int x, int y, int w, int h, int r, int g, int b, int a){ + SDL_Color color = {r, g, b, a}; + SDL_Surface *text = TTF_RenderText_Solid(RobotoFont, str, color); + SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, text); + rect.x = x; + rect.y = y; + rect.w = w; + rect.h = h; + SDL_RenderCopy(renderer, texture, NULL, &rect); + SDL_FreeSurface(text); + SDL_DestroyTexture(texture); +} + +void drawFPS(){ + char str[10]; + sprintf(str, "%d", (int)fps); + drawString(str, screenDimension.w - 50, 0, 50, 50, 255, 255, 255, 255); +} + void drawGame(){ SDL_RenderClear(renderer); drawSkyAndGround(); drawRays(map); drawMap2D(map); + drawFPS(); SDL_RenderPresent(renderer); } @@ -413,6 +436,7 @@ void mainLoop(){ delta = (a - b); if (delta > 1000/FPS_TO_GET){ //printf("fps: %f\n", 1000/delta); + fps = 1000/delta; b = a; switch (game_state){ case MENU: