Skip to content
Snippets Groups Projects
Commit a78e310f authored by belkhiritaha's avatar belkhiritaha
Browse files

ajout nextfire et score du joueur

parent a26bab1b
No related branches found
No related tags found
No related merge requests found
travail_de_groupe/chef_oeuvre/Res/nextFire.png

23.2 KiB

...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
......
90 10 0 0 0 50 50 0 0 0
0 80 20 0 0 0 60 40 0 0
0 10 80 10 0 0 10 70 20 0
0 0 10 50 40 0 0 10 50 40
0 0 0 50 50 0 0 0 100 0
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define STRONG 3 #define STRONG 3
#define SPREAD 4 #define SPREAD 4
#define UPDATETIME 10 #define UPDATETIME 5
typedef struct fire{ typedef struct fire{
......
...@@ -16,6 +16,7 @@ void initPlayer(){ ...@@ -16,6 +16,7 @@ void initPlayer(){
player.currentHP = player.HPMax; player.currentHP = player.HPMax;
player.invisible = 0; player.invisible = 0;
player.invisibleTime = 5; player.invisibleTime = 5;
player.score = 0;
} }
int giveCaseBelowPosition(int x, int y){ int giveCaseBelowPosition(int x, int y){
...@@ -189,6 +190,7 @@ void pourWater(int x, int y){ ...@@ -189,6 +190,7 @@ void pourWater(int x, int y){
//downgrade the cliqued fire //downgrade the cliqued fire
if(onFire == 1 && selectStateHover() == 1){ if(onFire == 1 && selectStateHover() == 1){
fireList = deleteFire (fireList, x, y); fireList = deleteFire (fireList, x, y);
player.score+=1;
} }
player.currentWater = player.currentWater - 1; player.currentWater = player.currentWater - 1;
} }
......
...@@ -24,6 +24,7 @@ typedef struct player{ ...@@ -24,6 +24,7 @@ typedef struct player{
int invisible; int invisible;
int invisibleTime; int invisibleTime;
int timeLastHitFire; int timeLastHitFire;
int score;
} player_t; } player_t;
extern player_t player; extern player_t player;
......
#include "render.h" #include "render.h"
int score = 100;
float timer = 0; float timer = 0;
SDL_Window *window; SDL_Window *window;
...@@ -76,6 +75,9 @@ SDL_Texture * heartTexture; ...@@ -76,6 +75,9 @@ SDL_Texture * heartTexture;
SDL_Surface * scoreSurface; SDL_Surface * scoreSurface;
SDL_Texture * scoreTexture; SDL_Texture * scoreTexture;
SDL_Surface * nextFireSurface;
SDL_Texture * nextFireTexture;
void createWindow(){ void createWindow(){
if (SDL_Init(SDL_INIT_VIDEO) != 0){ if (SDL_Init(SDL_INIT_VIDEO) != 0){
...@@ -297,7 +299,7 @@ void drawScore(){ ...@@ -297,7 +299,7 @@ void drawScore(){
SDL_RenderCopy(renderer, scoreTexture, NULL, &rect); SDL_RenderCopy(renderer, scoreTexture, NULL, &rect);
rect.y += rect.h; rect.y += rect.h;
char str[10]; char str[10];
//sprintf(str, "%d", score); sprintf(str, "%d", player.score);
SDL_Color textColor = {237,222,17}; SDL_Color textColor = {237,222,17};
SDL_Surface * surface = TTF_RenderText_Solid(robotoFont, str, textColor); SDL_Surface * surface = TTF_RenderText_Solid(robotoFont, str, textColor);
SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface); SDL_Texture * texture = SDL_CreateTextureFromSurface(renderer, surface);
...@@ -310,7 +312,7 @@ void drawTime(){ ...@@ -310,7 +312,7 @@ void drawTime(){
rect.w = (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2; rect.w = (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2;
rect.x = rect.w + (MAPSIZE * CELLSIZE); rect.x = rect.w + (MAPSIZE * CELLSIZE);
rect.y = 0; rect.y = 0;
SDL_RenderCopy(renderer, scoreTexture, NULL, &rect); SDL_RenderCopy(renderer, nextFireTexture, NULL, &rect);
rect.y += rect.h; rect.y += rect.h;
char str[10]; char str[10];
printf("%d\n", (UPDATETIME * 1000 - (int)timer % (UPDATETIME * 1000))/1000); printf("%d\n", (UPDATETIME * 1000 - (int)timer % (UPDATETIME * 1000))/1000);
...@@ -412,6 +414,9 @@ void mainLoop(){ ...@@ -412,6 +414,9 @@ void mainLoop(){
scoreSurface = IMG_Load("Res/score.png"); scoreSurface = IMG_Load("Res/score.png");
scoreTexture = SDL_CreateTextureFromSurface(renderer, scoreSurface); scoreTexture = SDL_CreateTextureFromSurface(renderer, scoreSurface);
nextFireSurface = IMG_Load("Res/nextFire.png");
nextFireTexture = SDL_CreateTextureFromSurface(renderer, nextFireSurface);
heartSurface = IMG_Load("Res/heart_spritesheet.png"); heartSurface = IMG_Load("Res/heart_spritesheet.png");
heartTexture = SDL_CreateTextureFromSurface(renderer, heartSurface); heartTexture = SDL_CreateTextureFromSurface(renderer, heartSurface);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment