diff --git a/travail_de_groupe/chef_oeuvre/src/gest_event.c b/travail_de_groupe/chef_oeuvre/src/gest_event.c index 7ea08e5402d367b665fc24bd8125efb4c354196d..caad8317dca7bb341842856eba8c5e14dff9a70a 100644 --- a/travail_de_groupe/chef_oeuvre/src/gest_event.c +++ b/travail_de_groupe/chef_oeuvre/src/gest_event.c @@ -123,10 +123,14 @@ void manageGame(){ break; case SDL_MOUSEMOTION: - mousePosition.x = (event.motion.x - (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2) / CELLSIZE; - mousePosition.y = (event.motion.y - 0) / CELLSIZE; + mousePosition.x = (event.motion.x - (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2) / CELLSIZE; + mousePosition.y = (event.motion.y - 0) / CELLSIZE; continue; + case SDL_MOUSEBUTTONDOWN: + pourWater(mousePosition.x, mousePosition.y); + break; + default: continue; } diff --git a/travail_de_groupe/chef_oeuvre/src/player.c b/travail_de_groupe/chef_oeuvre/src/player.c index d2112ebf0fb954eccb2776dca7f63031cc6f1542..cc5135b7b723da9287fb87cca4890714b0933639 100644 --- a/travail_de_groupe/chef_oeuvre/src/player.c +++ b/travail_de_groupe/chef_oeuvre/src/player.c @@ -4,11 +4,12 @@ player_t player; void initPlayer(){ - player.x = 18*32; - player.y = 0; + player.x = (MAPSIZE/2)*CELLSIZE; + player.y = (MAPSIZE/2)*CELLSIZE; player.w = CELLSIZE*0.8; player.h = CELLSIZE*0.8; - player.waterLevel = 3; + player.waterMax = 3; + player.currentWater = player.waterMax; player.speed = 1; player.isMoving = 0; } @@ -134,9 +135,15 @@ int selectStateHover(){ } -void pourWater(){ - player.waterLevel = player.waterLevel - 1; - +void pourWater(int x, int y){ + int onFire = searchFire(fireList, x, y); + if(player.currentWater>0){ + //downgrade the cliqued fire + if(onFire == 1 && selectStateHover() == 1){ + fireList = deleteFire (fireList, x, y); + } + player.currentWater = player.currentWater - 1; + } } diff --git a/travail_de_groupe/chef_oeuvre/src/player.h b/travail_de_groupe/chef_oeuvre/src/player.h index 8dda417ec6b48cac57240a0dc79a26c8748e4575..a8bcffb7d67bb15d6dfa6feaa4b19ef23b0a90f1 100644 --- a/travail_de_groupe/chef_oeuvre/src/player.h +++ b/travail_de_groupe/chef_oeuvre/src/player.h @@ -14,7 +14,8 @@ typedef struct player{ int y; int w; int h; - int waterLevel; + int currentWater; + int waterMax; int speed; int isMoving; } player_t; @@ -24,5 +25,6 @@ extern player_t player; void initPlayer(); void manageMovement(); int selectStateHover(); +void pourWater(int, int); #endif \ No newline at end of file