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

rendering fires as trees

parent 5127f031
No related branches found
No related tags found
No related merge requests found
#include "fire.h" #include "fire.h"
#include "map.h" #include "map.h"
listchainfire_t fireList;
int markov[SIZEMARKOV][SIZEMARKOV]; int markov[SIZEMARKOV][SIZEMARKOV];
listchainfire_t initFire (void) listchainfire_t initFire (void)
...@@ -52,7 +53,7 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){ ...@@ -52,7 +53,7 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){
srand(time(NULL)); srand(time(NULL));
xFire= rand()%mapSize; xFire= rand()%mapSize;
srand(time(NULL)); srand(time(NULL));
xFire= rand()%mapSize; yFire= rand()%mapSize;
fire.x= xFire; fire.x= xFire;
fire.y= yFire; fire.y= yFire;
...@@ -70,7 +71,7 @@ booleen_t searchFire(listchainfire_t listFire, int x ,int y) ...@@ -70,7 +71,7 @@ booleen_t searchFire(listchainfire_t listFire, int x ,int y)
{ {
booleen_t result = false; 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 if(((listFire->fire).x==x)&&((listFire->fire).y==y)) // si on trouve la semaine voulue
{ {
......
...@@ -27,6 +27,8 @@ typedef struct chain { ...@@ -27,6 +27,8 @@ typedef struct chain {
struct chain *next; struct chain *next;
}chainfire_t,*listchainfire_t; }chainfire_t,*listchainfire_t;
extern listchainfire_t fireList;
listchainfire_t initFire(void); listchainfire_t initFire(void);
booleen_t emptyListFire(listchainfire_t); booleen_t emptyListFire(listchainfire_t);
listchainfire_t insertAheadFire(fire_t, listchainfire_t); listchainfire_t insertAheadFire(fire_t, listchainfire_t);
......
...@@ -8,5 +8,6 @@ int main(){ ...@@ -8,5 +8,6 @@ int main(){
running = 1; running = 1;
gameState = MENU; gameState = MENU;
readMapFromFile("map.txt"); readMapFromFile("map.txt");
fireList = startFire(fireList,10,MAPSIZE);
mainLoop(); mainLoop();
} }
\ No newline at end of file
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "gest_event.h" #include "gest_event.h"
#include "map.h" #include "map.h"
#include "player.h" #include "player.h"
#include "fire.h"
#define MENU 0 #define MENU 0
......
...@@ -141,11 +141,25 @@ void drawBackgroundSides(){ ...@@ -141,11 +141,25 @@ void drawBackgroundSides(){
SDL_RenderCopy(renderer, backgroundSidesTexture, NULL, &rect); 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(){ void drawGame(){
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
drawBackgroundSides(); drawBackgroundSides();
drawMap(); drawMap();
drawPlayer(); drawPlayer();
drawFire();
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment