Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pakumanEatSomething(character c,int map[MAP_HEIGHT_MAX][MAP_WIDTH_MAX]){
- int mapXmin, mapYmin, mapXmax, mapYmax;
- int food=0;
- // Récupération des coordonnées (mapXmin, mapYmin) de la map correspondant au coin Haut-Gauche du pakuman en utilisant les coordonnées (x,y) du pakuman dans le repère écran
- mapXmin =(c.p.x)/30;
- mapYmin =(c.p.y)/30;
- // Récupération des coordonnées (mapXmax, mapYmax) de la map correspondant au coin Bas-Droit du pakuman en utilisant les coordonnées (x,y) du pakuman dans le repère écran et la taille du pakuman
- mapXmax = (c.p.x + (c.size))/30;
- mapYmax = (c.p.y + (c.size))/30;
- // Si le coins Haut-Gauche n'est ni dans une case de mur, ni une case vide
- if (map[mapYmin][mapXmin] != EMPTY && map[mapYmin][mapXmin] != WALL){
- // On récupère ce qu'il y a dans la case
- food = map[mapYmin][mapXmin] = EMPTY;
- // On "vide" la case (élément EMPTY)
- map[mapYmin][mapXmin]= EMPTY;
- }
- // Idem pour le coins Bas-Droit
- if (map[mapYmax][mapXmax] != EMPTY && map[mapYmax][mapXmax] != WALL){
- food = map[mapYmax][mapXmax] = EMPTY;
- map[mapYmin][mapXmin]= EMPTY;
- }
- // Idem pour le coins Haut-Droit
- if (map[mapYmin][mapXmax] != EMPTY && map[mapYmin][mapXmax] != WALL){
- food = map[mapYmin][mapXmax] = EMPTY;
- map[mapYmin][mapXmax]= EMPTY;
- }
- // Idem pour le coins Bas-Gauche n'est ni dans une case de mur, ni une case vide
- if (map[mapYmax][mapXmin] != EMPTY && map[mapYmax][mapXmin] != WALL){
- food = map[mapYmax][mapXmin] = EMPTY;
- map[mapYmax][mapXmin]= EMPTY;
- }
- return food;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement