Skip to content
Snippets Groups Projects
Commit ea11a665 authored by maberet's avatar maberet
Browse files

Génération du feu'

parent 5d6ac0d2
No related branches found
No related tags found
No related merge requests found
...@@ -45,16 +45,17 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){ ...@@ -45,16 +45,17 @@ listchainfire_t startFire(listchainfire_t listFire,int numberFire, int mapSize){
int i; int i;
int xFire=0; int xFire=0;
int yFire=0; int yFire=0;
srand(time(NULL));
fire_t fire; fire_t fire;
if (emptyListFire(listFire)){ if (emptyListFire(listFire)){
for (i=0;i<numberFire;i++){ for (i=0;i<numberFire;i++){
srand(time(NULL));
xFire= rand()%mapSize; xFire= rand()%mapSize;
srand(time(NULL));
yFire= rand()%mapSize;
yFire= rand()%mapSize;
printf("xf:%d,yf:%d\n",xFire,yFire);
fire.x= xFire; fire.x= xFire;
fire.y= yFire; fire.y= yFire;
fire.state=1; fire.state=1;
...@@ -126,3 +127,13 @@ listchainfire_t offFire (listchainfire_t listFire, int x ,int y ){ ...@@ -126,3 +127,13 @@ listchainfire_t offFire (listchainfire_t listFire, int x ,int y ){
} }
return listFire; return listFire;
} }
void travelFire(listchainfire_t listFire){
listchainfire_t listTemporary=listFire;
while(listTemporary!=NULL){
printf("x:%d,y:%d\n",(listTemporary->fire).x,(listTemporary->fire).y);
listTemporary=listTemporary->next;
}
//freeListFire(listTemporary);
}
\ No newline at end of file
...@@ -38,5 +38,6 @@ listchainfire_t deleteAheadFire(listchainfire_t); ...@@ -38,5 +38,6 @@ listchainfire_t deleteAheadFire(listchainfire_t);
listchainfire_t deleteFire (listchainfire_t, int ,int ); listchainfire_t deleteFire (listchainfire_t, int ,int );
listchainfire_t freeListFire (listchainfire_t ); listchainfire_t freeListFire (listchainfire_t );
listchainfire_t offFire (listchainfire_t, int,int ); listchainfire_t offFire (listchainfire_t, int,int );
void travelFire(listchainfire_t listFire);
#endif #endif
\ No newline at end of file
...@@ -9,5 +9,6 @@ int main(){ ...@@ -9,5 +9,6 @@ int main(){
gameState = MENU; gameState = MENU;
readMapFromFile("map.txt"); readMapFromFile("map.txt");
fireList = startFire(fireList,10,MAPSIZE); fireList = startFire(fireList,10,MAPSIZE);
travelFire(fireList);
mainLoop(); mainLoop();
} }
\ No newline at end of file
...@@ -147,8 +147,8 @@ void drawFire(){ ...@@ -147,8 +147,8 @@ void drawFire(){
SDL_Rect rect; SDL_Rect rect;
rect.h = CELLSIZE; rect.h = CELLSIZE;
rect.w = CELLSIZE; rect.w = CELLSIZE;
rect.x = (cour->fire).x + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2; rect.x = (cour->fire).x*CELLSIZE + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2;
rect.y = (cour->fire).y ; rect.y = (cour->fire).y*CELLSIZE ;
SDL_RenderCopy(renderer, treeTexture, NULL, &rect); SDL_RenderCopy(renderer, treeTexture, NULL, &rect);
cour = cour->next; cour = cour->next;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment