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

Merge branch 'player' into main

parents 31f38fba d2d9d4bf
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment