diff --git a/travail_de_groupe/chef_oeuvre/src/fire.c b/travail_de_groupe/chef_oeuvre/src/fire.c index 3a8f4b4dfd5bb58a8f8936e11866b0c3da940a0b..ae254e143506d448d271a7311293975f22a1bade 100644 --- a/travail_de_groupe/chef_oeuvre/src/fire.c +++ b/travail_de_groupe/chef_oeuvre/src/fire.c @@ -1,6 +1,7 @@ #include "fire.h" #include "map.h" +listchainfire_t fireList; int markov[SIZEMARKOV][SIZEMARKOV]; listchainfire_t initFire (void) @@ -52,7 +53,7 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){ srand(time(NULL)); xFire= rand()%mapSize; srand(time(NULL)); - xFire= rand()%mapSize; + yFire= rand()%mapSize; fire.x= xFire; fire.y= yFire; @@ -70,7 +71,7 @@ booleen_t searchFire(listchainfire_t listFire, int x ,int y) { booleen_t result = false; - while((listFire!=NULL)||!(result)) + while((listFire!=NULL)&&!(result)) { if(((listFire->fire).x==x)&&((listFire->fire).y==y)) // si on trouve la semaine voulue { diff --git a/travail_de_groupe/chef_oeuvre/src/fire.h b/travail_de_groupe/chef_oeuvre/src/fire.h index ce6b5a81f1145aaf7de6eb428a6b40703e923603..851423fb3baf8be731b2ebdd59ca530322079345 100644 --- a/travail_de_groupe/chef_oeuvre/src/fire.h +++ b/travail_de_groupe/chef_oeuvre/src/fire.h @@ -27,6 +27,8 @@ typedef struct chain { struct chain *next; }chainfire_t,*listchainfire_t; +extern listchainfire_t fireList; + listchainfire_t initFire(void); booleen_t emptyListFire(listchainfire_t); listchainfire_t insertAheadFire(fire_t, listchainfire_t); diff --git a/travail_de_groupe/chef_oeuvre/src/main.c b/travail_de_groupe/chef_oeuvre/src/main.c index d614bddfb4a48fd373628e8c3497125115224e9d..5b23e5321ad0db2016014b8e655c5ca254da132a 100644 --- a/travail_de_groupe/chef_oeuvre/src/main.c +++ b/travail_de_groupe/chef_oeuvre/src/main.c @@ -8,5 +8,6 @@ int main(){ running = 1; gameState = MENU; readMapFromFile("map.txt"); + fireList = startFire(fireList,10,MAPSIZE); mainLoop(); } \ No newline at end of file diff --git a/travail_de_groupe/chef_oeuvre/src/main.h b/travail_de_groupe/chef_oeuvre/src/main.h index 8c5c5178c9425d21747c33d2e55640ec6f38a032..a898cd4a75c5e164e4781f6a28deec163f31c3b1 100644 --- a/travail_de_groupe/chef_oeuvre/src/main.h +++ b/travail_de_groupe/chef_oeuvre/src/main.h @@ -18,6 +18,7 @@ #include "gest_event.h" #include "map.h" #include "player.h" +#include "fire.h" #define MENU 0 diff --git a/travail_de_groupe/chef_oeuvre/src/render.c b/travail_de_groupe/chef_oeuvre/src/render.c index 21fafd8e148ecbc4a7726d1c5f6da3afc13a3f31..f543c0e607b9cec9fd2f060b58aa22457d67f365 100644 --- a/travail_de_groupe/chef_oeuvre/src/render.c +++ b/travail_de_groupe/chef_oeuvre/src/render.c @@ -141,11 +141,25 @@ void drawBackgroundSides(){ SDL_RenderCopy(renderer, backgroundSidesTexture, NULL, &rect); } +void drawFire(){ + listchainfire_t cour = fireList; + while (cour != NULL){ + SDL_Rect rect; + rect.h = CELLSIZE; + rect.w = CELLSIZE; + rect.x = (cour->fire).x + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2; + rect.y = (cour->fire).y ; + SDL_RenderCopy(renderer, treeTexture, NULL, &rect); + cour = cour->next; + } +} + void drawGame(){ SDL_RenderClear(renderer); drawBackgroundSides(); drawMap(); drawPlayer(); + drawFire(); SDL_RenderPresent(renderer); }