diff --git a/travail_de_groupe/chef_oeuvre/markov.txt b/travail_de_groupe/chef_oeuvre/markov.txt index c4cf89492020cbd533b14d1f8cc37d9b72969f25..5a5f989e4d61b12dad907467cb58fc1dd38f067b 100644 --- a/travail_de_groupe/chef_oeuvre/markov.txt +++ b/travail_de_groupe/chef_oeuvre/markov.txt @@ -1,5 +1,5 @@ -1 0 0 0 0 -0 1 0 0 0 -0 0 1 0 0 -0 0 0 1 0 -0 0 0 0 1 \ No newline at end of file +90 10 0 0 0 +0 80 20 0 0 +0 10 80 10 0 +0 0 10 50 40 +0 0 0 50 50 \ No newline at end of file diff --git a/travail_de_groupe/chef_oeuvre/src/fire.c b/travail_de_groupe/chef_oeuvre/src/fire.c index 9794417cd01364e2e3cf27352f725524c3fd27f3..61289d5cbc08e62603c62e46da4c5877bfc4b9f0 100644 --- a/travail_de_groupe/chef_oeuvre/src/fire.c +++ b/travail_de_groupe/chef_oeuvre/src/fire.c @@ -170,13 +170,13 @@ void nextFire(listchainfire_t listFire){ state=(listTemporary->fire).state; probability= rand()%101; - pDead=markov[state][DEAD]*100; - pSparkle=(markov[state][SPARKLE]+markov[state][DEAD])*100; + pDead=markov[state][DEAD]; + pSparkle=(markov[state][SPARKLE]+markov[state][DEAD]); - pMedium=(markov[state][SPARKLE]+markov[state][DEAD]+markov[state][MEDIUM])*100; + pMedium=(markov[state][SPARKLE]+markov[state][DEAD]+markov[state][MEDIUM]); pStrong=(markov[state][SPARKLE]+markov[state][DEAD]+ - markov[state][MEDIUM]+markov[state][STRONG])*100; + markov[state][MEDIUM]+markov[state][STRONG]); if ((0<=probability)&&(probability<pDead)){(listTemporary->fire).state=DEAD;} diff --git a/travail_de_groupe/chef_oeuvre/src/render.c b/travail_de_groupe/chef_oeuvre/src/render.c index 8b2c1b966ec3f82c2600937a9ad297cf18485477..bd59f1623b019c0479fe0ffeef9fc0041449030a 100644 --- a/travail_de_groupe/chef_oeuvre/src/render.c +++ b/travail_de_groupe/chef_oeuvre/src/render.c @@ -174,18 +174,48 @@ void drawBackgroundSides(){ } void drawFire(){ + int loop; + int step; listchainfire_t cour = fireList; SDL_Rect rect; + rect.h = CELLSIZE; + rect.w = CELLSIZE; SDL_Rect srcRect; - srcRect.w = 24; - srcRect.h =32; - srcRect.x = srcRect.w * (SDL_GetTicks()/200 % 8); - srcRect.y= 0; while (cour != NULL){ - rect.h = CELLSIZE * (cour->fire).state; - rect.w = CELLSIZE * (cour->fire).state; - rect.x = (cour->fire).x * CELLSIZE + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2 - rect.w/2; - rect.y = (cour->fire).y * CELLSIZE; + rect.x = (cour->fire).x * CELLSIZE + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2; + rect.y = (cour->fire).y * CELLSIZE - rect.h/2; + + srcRect.w = 15; + srcRect.h =24; + srcRect.x = step + srcRect.w * (SDL_GetTicks()/200 % loop); + srcRect.y= 0; + + switch ((cour->fire).state) + { + case SPARKLE: + step = 0; + loop = 2; + break; + + case MEDIUM: + step = 2 * srcRect.w; + loop = 4; + break; + + case STRONG: + step = 6 * srcRect.w; + loop = 6; + break; + + case SPREAD: + step = 6 * srcRect.w; + loop = 6; + break; + + default: + break; + } + SDL_RenderCopy(renderer, fireTexture, &srcRect, &rect); cour = cour->next; } @@ -271,7 +301,7 @@ void mainLoop(){ playButtonHoverSurface = IMG_Load("Res/play_button_hover.png"); playButtonHoverTexture = SDL_CreateTextureFromSurface(renderer, playButtonHoverSurface); - fireSurface = IMG_Load("Res/fire.png"); + fireSurface = IMG_Load("Res/fire_spritesheet.png"); fireTexture = SDL_CreateTextureFromSurface(renderer, fireSurface); waterSurface = IMG_Load("Res/water.png"); @@ -325,6 +355,9 @@ void mainLoop(){ drawMenu(); break; case GAME: + if ((int)timer % 20 == 0){ + nextFire(fireList); + } drawGame(); break; }