diff --git a/travail_de_groupe/chef_oeuvre/src/fire.c b/travail_de_groupe/chef_oeuvre/src/fire.c index 6dd301fa72cfe11447f0d1171457e613fb4078d8..ce1f573300e208a21c4040ac130f3d43ef1ba8e0 100644 --- a/travail_de_groupe/chef_oeuvre/src/fire.c +++ b/travail_de_groupe/chef_oeuvre/src/fire.c @@ -36,6 +36,9 @@ listchainfire_t insertAheadFire(fire_t fire,listchainfire_t listFire) m->next= listFire; listFire=m; } + else { + free(m); + } return listFire; } @@ -57,7 +60,7 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){ yFire= rand()%mapSize; fire.x= xFire; fire.y= yFire; - fire.state=1; + fire.state=2; listFire=insertAheadFire(fire, listFire); diff --git a/travail_de_groupe/chef_oeuvre/src/fire.h b/travail_de_groupe/chef_oeuvre/src/fire.h index 9d4b7d7593944768126abb5ca0bbc480575ab4b9..125c761db9d63acd407f71b8c87b0cb8bc7b3761 100644 --- a/travail_de_groupe/chef_oeuvre/src/fire.h +++ b/travail_de_groupe/chef_oeuvre/src/fire.h @@ -13,7 +13,7 @@ #define STRONG 3 #define SPREAD 4 -#define UPDATETIME 5 +#define UPDATETIME 3 typedef struct fire{ diff --git a/travail_de_groupe/chef_oeuvre/src/render.c b/travail_de_groupe/chef_oeuvre/src/render.c index 47eebfd7230a32035c795eaf2ba0f730594566a9..f8facc890762b2fb7518567a71171a9f3af29858 100644 --- a/travail_de_groupe/chef_oeuvre/src/render.c +++ b/travail_de_groupe/chef_oeuvre/src/render.c @@ -114,6 +114,40 @@ void createWindow(){ } +void endSDL(){ + SDL_DestroyTexture(grassTexture); + SDL_DestroyTexture(treeTexture); + SDL_DestroyTexture(hoverTexture); + SDL_DestroyTexture(noHoverTexture); + SDL_DestroyTexture(playerTexture); + SDL_DestroyTexture(playerIdleTexture); + SDL_DestroyTexture(backgroundTexture); + SDL_DestroyTexture(backgroundSidesTexture); + SDL_DestroyTexture(backgroundLostTexture); + SDL_DestroyTexture(playButtonTexture); + SDL_DestroyTexture(playButtonHoverTexture); + SDL_DestroyTexture(playAgainButtonTexture); + SDL_DestroyTexture(playAgainButtonHoverTexture); + SDL_DestroyTexture(quitButtonTexture); + SDL_DestroyTexture(quitButtonHoverTexture); + SDL_DestroyTexture(fireTexture); + SDL_DestroyTexture(waterTexture); + SDL_DestroyTexture(emptyBucketTexture); + SDL_DestroyTexture(filledBucketTexture); + SDL_DestroyTexture(heartTexture); + SDL_DestroyTexture(scoreTexture); + SDL_DestroyTexture(nextFireTexture); + SDL_DestroyTexture(backgroundWonTexture); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + TTF_CloseFont(robotoFont); + TTF_Quit(); + SDL_Quit(); + if (!fireList){ + fireList = freeListFire(fireList); + } +} + void drawBackground(){ SDL_Rect rect = {0, 0, screenDimension.w, screenDimension.h}; SDL_RenderCopy(renderer, backgroundTexture, NULL, &rect); @@ -322,7 +356,7 @@ void drawTime(){ SDL_RenderCopy(renderer, nextFireTexture, NULL, &rect); rect.y += rect.h; char str[10]; - printf("%d\n", (UPDATETIME * 1000 - (int)timer % (UPDATETIME * 1000))/1000); + //printf("%d\n", (UPDATETIME * 1000 - (int)timer % (UPDATETIME * 1000))/1000); sprintf(str, "%d", (UPDATETIME * 1000 - (int)timer % (UPDATETIME * 1000))/1000); SDL_Color textColor = {237,222,17}; SDL_Surface * surface = TTF_RenderText_Solid(robotoFont, str, textColor); @@ -519,7 +553,7 @@ void mainLoop(){ if (delta > 1000/FPS_TO_GET){ fps = 1000/delta; timer += delta; - printf("%d\n", (int)timer % 1000); + //printf("%d\n", (int)timer % 1000); b = a; switch (gameState){ case MENU: @@ -550,6 +584,6 @@ void mainLoop(){ // fait dormir le thread pour garder des ressources usleep(1000 * (1000/FPS_TO_GET - delta)); } - } + endSDL(); } \ No newline at end of file