Skip to content
Snippets Groups Projects
Commit 4ca62c4e authored by Taha Belkhiri's avatar Taha Belkhiri
Browse files

ajout de tout les free

parent cb8a50b8
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -13,7 +13,7 @@
#define STRONG 3
#define SPREAD 4
#define UPDATETIME 5
#define UPDATETIME 3
typedef struct fire{
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment