Skip to content
Snippets Groups Projects
Commit d2d9d4bf authored by antoinemeyer5's avatar antoinemeyer5
Browse files

eteindre les feux

parent 149a1267
No related branches found
No related tags found
No related merge requests found
......@@ -127,6 +127,10 @@ void manageGame(){
mousePosition.y = (event.motion.y - 0) / CELLSIZE;
continue;
case SDL_MOUSEBUTTONDOWN:
pourWater(mousePosition.x, mousePosition.y);
break;
default:
continue;
}
......
......@@ -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;
}
}
......@@ -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
......@@ -153,7 +153,6 @@ void drawFire(){
srcRect.x = srcRect.w * (SDL_GetTicks()/200 % 8);
srcRect.y= 0;
while (cour != NULL){
printf("%p %d %d\n", (cour->fire), (cour->fire).x, (cour->fire).x);
rect.h = CELLSIZE;
rect.w = CELLSIZE;
rect.x = (cour->fire).x * CELLSIZE + (screenDimension.w - (MAPSIZE * CELLSIZE)) / 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment