Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. int pakumanEatSomething(character c,int map[MAP_HEIGHT_MAX][MAP_WIDTH_MAX]){
  2. int mapXmin, mapYmin, mapXmax, mapYmax;
  3. int food=0;
  4. // 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
  5. mapXmin =(c.p.x)/30;
  6. mapYmin =(c.p.y)/30;
  7.  
  8. // 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
  9. mapXmax = (c.p.x + (c.size))/30;
  10. mapYmax = (c.p.y + (c.size))/30;
  11.  
  12.  
  13. // Si le coins Haut-Gauche n'est ni dans une case de mur, ni une case vide
  14. if (map[mapYmin][mapXmin] != EMPTY && map[mapYmin][mapXmin] != WALL){
  15. // On récupère ce qu'il y a dans la case
  16. food = map[mapYmin][mapXmin] = EMPTY;
  17. // On "vide" la case (élément EMPTY)
  18. map[mapYmin][mapXmin]= EMPTY;
  19. }
  20.  
  21. // Idem pour le coins Bas-Droit
  22. if (map[mapYmax][mapXmax] != EMPTY && map[mapYmax][mapXmax] != WALL){
  23. food = map[mapYmax][mapXmax] = EMPTY;
  24. map[mapYmin][mapXmin]= EMPTY;
  25. }
  26. // Idem pour le coins Haut-Droit
  27. if (map[mapYmin][mapXmax] != EMPTY && map[mapYmin][mapXmax] != WALL){
  28. food = map[mapYmin][mapXmax] = EMPTY;
  29. map[mapYmin][mapXmax]= EMPTY;
  30. }
  31. // Idem pour le coins Bas-Gauche n'est ni dans une case de mur, ni une case vide
  32. if (map[mapYmax][mapXmin] != EMPTY && map[mapYmax][mapXmin] != WALL){
  33. food = map[mapYmax][mapXmin] = EMPTY;
  34. map[mapYmax][mapXmin]= EMPTY;
  35. }
  36.  
  37.  
  38. return food;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement