1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
|
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fmodex/fmod.h>
#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>
#define PAUSE 100000 // Duree en micro secondes d'un passage de boucle
#define XINIT 1 // Position initiale du pacman (ligne)
#define YINIT 1 // Position initiale du pacman (colonne)
#define MUR 1 // La case de la grille est un mur
#define POINT 0 // La case contient un point que le Pacman peut prendre
#define VIDE 2 // Case vide que le Pacman peut traverser
#define NB_L 21 // Nombre de lignes du labyrinthe
#define NB_C 21 // Nombre de colonnes du labyrinthe
#define TAILLE_CARRE 50 // On définie la taille d'un carreau
#define NIVEAU 150 // Couleur du mur du mat
#define DROITE 1 // Déplacement à gauche du pacman
#define GAUCHE 2 // Déplacement à droite du pacman
#define HAUT 3 // Déplacement en haut du pacman
#define BAS 4 // Déplacement en bas du pacman
#define A_DROITE 0 // Déplacement à droite des monstres
#define EN_BAS 1 // Déplacement en bas des monstres
#define A_GAUCHE 2 // Déplacement à gauche des monstres
#define EN_HAUT 3 // Déplacement en haut des monstres
#define NB_MONSTRES 3 // Nombre de monstres dans le jeu
#define DIST_MAX 15 // Distance minimal pour que les monstres suivent le pacman
typedef int TableauMonstre[NB_MONSTRES][3];
TableauMonstre monstres={{1,19,1},{19,1,0},{19,19,2}};
int tabDirection [4][2] = {{0,1},{1,0},{0,-1},{-1,0}};
typedef int Tableau2D[NB_L][NB_C]; //type matrice pour représenter le mat
//boucle principale du programme
void Pacman(Tableau2D , SDL_Surface * ,SDL_Surface *[NB_L][NB_C], FMOD_SYSTEM *, FMOD_SOUND * [], FMOD_CHANNEL *) ;
/*
* La procédure suivante set à créer le maillage dans la fenêtre principale :
* on alloue dynamiquement la mémoire pour les rectangles
*/
void Init_Surface (SDL_Surface * [NB_L][NB_C]) ;
/*
* La procédure suivante remplie une case du maillage avec de la couleur
*/
void DessineUneCaseDuLabyrinthe \
(Tableau2D ,SDL_Surface * ,SDL_Surface * [NB_L][NB_C],int , int ) ;
/*
* La procédure suivante utilise la fonction précédente :
* elle permet de représenter toutes les cases du maillage
*/
void DessinLabyrinthe \
(Tableau2D mat, SDL_Surface * ecran, SDL_Surface * S[NB_L][NB_C]) ;
/*
* La procédure suivante libère la mémoire allouée dynamiquement
*/
void Free (SDL_Surface * [NB_L] [NB_C], FMOD_SYSTEM *, FMOD_SOUND * []) ;
/*
* La procédure suivante dessine le pacman à la position indiquée
* L'avant dernier entier correspond à la direction de la bouche et
* Le dernier entier correspond à l'état de la bouche.
*/
void DessinPac (SDL_Surface * [NB_L][NB_C],SDL_Surface *, int, int, int, int) ;
/*
* La procédure suivante calcule la position suivante du pacman par appui sur une
* touche de direction
* 1 : gauche 2 : droite 3 : haut 4 : bas
*/
void PositionSuivPacman (int *, int *, Tableau2D, int) ;
/*
* La fonction suivante efface l'ancienne position du pacman
* et appelle PositionSuivPacman pour trouver la position suivante
* Elle renvoie 1 si elle mange un point et 0 sinon
*/
int DeplacePacman (int *, int *, int *, Tableau2D, SDL_Surface *, SDL_Surface * [NB_L][NB_C], int, int) ;
/*
* La procédure suivante calcule la position suivante de chaque monstres, le déplacement
* des monstres est aléatoire mais il ne doivent pas retourner sur la case précédente.
* Les deux procédures qui suivent servent à dessiner les monstres
*/
void PositionSuivMonstres (int *, int *,int *, Tableau2D) ;
void DessinMonstre (SDL_Surface * [NB_L][NB_C],SDL_Surface * , int , int , int ) ;
void DessinMonstres (SDL_Surface * [NB_L][NB_C], SDL_Surface *, TableauMonstre, int, int, int, Tableau2D, int) ;
int MangerParlesMonstres (TableauMonstre , int ,int , int) ;
// Programme principal
int main(int argc, char *argv[])
{
SDL_Surface * ecran = NULL ;
SDL_Surface * Labyrinthe [NB_L][NB_C] ;
FMOD_SYSTEM * system ;
FMOD_SOUND * pac[5] ;
FMOD_CHANNEL * channel ;
// matrice du mat : 1 pour un mur, 0 pour du vide
Tableau2D matrice = \
{{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,2,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1},
{1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1},
{1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1},
{1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1},
{1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1},
{1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1},
{1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1},
{1,1,1,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,1,1,1},
{1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1},
{1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,0,0,0,0,0,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1},
{1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1},
{1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,0,1},
{1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1},
{1,0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,0,1},
{1,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
// Initialisation de la SDL
if (SDL_Init(SDL_INIT_VIDEO) == -1)
{
fprintf(stderr, "Erreur d'initialisation de la SDL") ;
exit (EXIT_FAILURE) ;
}
// Initialisation de TTF - bibliothèque pour écrire
if (TTF_Init () == -1)
{
fprintf(stderr, "Erreur d'initialisation de TTF_Init : %s\n", TTF_GetError ()) ;
exit (EXIT_FAILURE) ;
}
// Initialisation de l'objet système pour le son
FMOD_System_Create (&system) ;
FMOD_System_Init (system, 5, FMOD_INIT_NORMAL, NULL) ;
// Chargement du fichier son
FMOD_System_CreateSound (system, "bruit.wav", FMOD_CREATESAMPLE, 0, &pac[0]) ;
FMOD_System_CreateSound \
(system, "pacman.mp3", FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM | FMOD_LOOP_NORMAL, 0, &pac[1]) ;
FMOD_System_CreateSound (system, "pacmort1.wav", FMOD_CREATESAMPLE, 0, &pac[2]) ;
FMOD_System_CreateSound (system, "pacmort0.wav", FMOD_CREATESAMPLE, 0, &pac[3]) ;
FMOD_System_CreateSound (system, "pacmort.wav", FMOD_CREATESAMPLE, 0, &pac[4]) ;
//FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, mus, 0, NULL) ;
FMOD_Sound_SetLoopCount (pac[1], -1) ;
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[1], 0, &channel) ;
// Ouverture de la fenêtre principale
ecran = SDL_SetVideoMode(NB_L*TAILLE_CARRE ,NB_C*TAILLE_CARRE + 70, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (ecran == NULL)
{
fprintf(stderr, "Impossible de charger le mode video : %s\n", SDL_GetError()) ;
}
SDL_WM_SetCaption ("Jeu de Pacman","pack") ;
//SDL_EnableKeyRepeat (10, 10) ;
Pacman (matrice, ecran, Labyrinthe, system, pac, channel); // Lancement du jeu
Free (Labyrinthe, system, pac) ;
TTF_Quit () ;
SDL_Quit(); // Arrêt de la SDL
return EXIT_SUCCESS; // Fermeture du programme
}
/**************************************************************************************************/
void Free (SDL_Surface * laby [NB_L] [NB_C], FMOD_SYSTEM * s, FMOD_SOUND * son [5])
{
int i,j ;
for (i=0; i<NB_L; i++) {
for (j=0; j<NB_C; j++) SDL_FreeSurface (laby [i][j]) ;
}
FMOD_System_Close (s) ;
FMOD_System_Release (s) ;
//for (i=0; i<2; i++) FMOD_Sound_Release (son [i]) ;
}
/**************************************************************************************************/
void Pacman \
(Tableau2D mat, SDL_Surface * ecran,SDL_Surface * S [NB_L][NB_C], FMOD_SYSTEM *system, FMOD_SOUND *pac[5], FMOD_CHANNEL * ch )
{
int continuer = 1;
int i ;
SDL_Event event;
int l = XINIT ;
int c = YINIT ;
int lprec ;
int cprec ;
int nbPoints = 0 ;
int croise = 0 ;
int key ;
int compteur = 0 ;
int choix_im = 0 ;
int mange ;
int foutu = 0 ;
int lm [NB_MONSTRES] ;
int cm [NB_MONSTRES] ;
char chaine [20] ;
char chaine1 [20] ;
TTF_Font * police = NULL ;
SDL_Surface * texte = NULL ;
SDL_Surface * bande = NULL ;
SDL_Color C0 = {200, 0, 0} ;
SDL_Rect position ;
position.x = 20 ;
position.y = NB_C*TAILLE_CARRE ;
bande = SDL_CreateRGBSurface (SDL_HWSURFACE, NB_L*TAILLE_CARRE ,70,32,0,0,0,0) ;
police = TTF_OpenFont ("pol2.ttf", 65) ;
texte = TTF_RenderText_Blended (police, "PACMAN ", C0) ;
SDL_BlitSurface (texte, NULL, ecran, &position) ;
Init_Surface (S) ;
DessinLabyrinthe (mat, ecran, S) ;
DessinPac (S,ecran,XINIT,YINIT,DROITE, choix_im) ;
while (continuer && !foutu)
{
// on teste si on déplace le packman : non bloquant
lprec = l ;
cprec = c ;
mange = 0 ;
SDL_Flip (ecran) ;
SDL_PollEvent(&event);
switch(event.type)
{
case SDL_QUIT :
exit (0);
case SDL_KEYDOWN :
{
switch (event.key.keysym.sym)
{
case SDLK_k :
{
mange = DeplacePacman (&l, &c, &nbPoints, mat, ecran, S, HAUT, choix_im) ;
break ;
}
case SDLK_j :
{
mange = DeplacePacman (&l, &c, &nbPoints, mat, ecran, S, BAS, choix_im) ;
break ;
}
case SDLK_l :
{
mange = DeplacePacman (&l, &c, &nbPoints, mat, ecran, S, DROITE, choix_im) ;
break ;
}
case SDLK_h :
{
mange = DeplacePacman (&l, &c, &nbPoints, mat, ecran, S, GAUCHE, choix_im) ;
break ;
}
case SDLK_SPACE : // pour faire une pause
{
int cont = 1 ;
while (cont)
{
SDL_WaitEvent(&event) ;
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) cont = 0 ;
}
break ;
}
}
if (mange == 1) {
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[0], 0, NULL) ;
nbPoints++ ;
position.x=300 ;
position.y= NB_L*TAILLE_CARRE ;
SDL_BlitSurface (bande, NULL, ecran, &position) ;
sprintf(chaine, "Score : %d", nbPoints) ;
position.x = NB_C*TAILLE_CARRE - 300 ;
position.y = NB_L*TAILLE_CARRE + TAILLE_CARRE/3 ;
police = TTF_OpenFont ("pol2.ttf", 40) ;
texte = TTF_RenderText_Blended (police, chaine, C0) ;
SDL_BlitSurface (texte, NULL, ecran, &position) ;
}
}
}
// On réalise les autres opérations du jeu
usleep (PAUSE) ;
if (choix_im == 0) {
for (i=0; i < NB_MONSTRES; i++) {
lm [i] = monstres [i][0] ;
cm [i] = monstres [i][1] ;
}
DessinMonstres (S, ecran, monstres, NB_MONSTRES, l, c, mat, 1) ;
for (i=0; i < NB_MONSTRES; i++) {
if (lm[i] == l && cm[i] == c && monstres [i][0] == lprec && monstres [i][1] == cprec) {
foutu = 1 ;
SDL_Flip (ecran) ;
FMOD_Channel_Stop (ch) ;
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[2], 0, NULL) ;
sleep (1) ;
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[3], 0, NULL) ;
//sleep (1) ;
//FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[4], 0, NULL) ;
}
}
}
if (MangerParlesMonstres (monstres, NB_MONSTRES, l, c)) {
foutu = 1 ;
SDL_Flip (ecran) ;
FMOD_Channel_Stop (ch) ;
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[2], 0, NULL) ;
sleep (1) ;
FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[3], 0, NULL) ;
//sleep (1) ;
//FMOD_System_PlaySound (system, FMOD_CHANNEL_FREE, pac[4], 0, NULL) ;
}
choix_im = ++compteur%3 ;
}
int cont = 1 ;
while (cont && continuer)
{
SDL_WaitEvent(&event) ;
if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE) cont = 0 ;
}
TTF_CloseFont (police) ;
}
/**************************************************************************************************/
void Init_Surface (SDL_Surface * laby [NB_L][NB_C])
{
int i, j ;
for (i=0; i<NB_L; i++) {
for (j=0; j<NB_C; j++) {
laby [i][j] = \
SDL_CreateRGBSurface (SDL_HWSURFACE,TAILLE_CARRE,TAILLE_CARRE,32,0,0,0,0) ;
}
}
}
/**************************************************************************************************/
void DessineUneCaseDuLabyrinthe \
(Tableau2D mat, SDL_Surface * ecran,SDL_Surface * S [NB_L][NB_C],int l, int c)
{
SDL_Rect position ;
if (mat [l][c] == 1) { SDL_FillRect (S[l][c],NULL,SDL_MapRGB \
(ecran->format,NIVEAU,NIVEAU,NIVEAU)) ;
position.x = c*TAILLE_CARRE ;
position.y = l*TAILLE_CARRE ;
}
else if (mat[l][c] == 0) {
SDL_FillRect (S[l][c],NULL,SDL_MapRGB(ecran->format,0,0,0)) ;
position.x = c*TAILLE_CARRE ;
position.y = l*TAILLE_CARRE ;
SDL_BlitSurface (S[l][c], NULL, ecran, &position) ;
S[l][c] = SDL_LoadBMP ("PointPacman.bmp") ;
position.x = c*TAILLE_CARRE + TAILLE_CARRE/2 ;
position.y = l*TAILLE_CARRE + TAILLE_CARRE/2 ;
}
else if (mat [l][c] == 2) { SDL_FillRect (S[l][c],NULL,SDL_MapRGB \
(ecran->format,0,0,0)) ;
position.x = c*TAILLE_CARRE ;
position.y = l*TAILLE_CARRE ;
}
SDL_BlitSurface (S[l][c], NULL, ecran, &position) ;
}
/**************************************************************************************************/
void DessinLabyrinthe (Tableau2D mat, SDL_Surface * ecran, SDL_Surface * S[NB_L][NB_C])
{
int i, j ;
for (i=0; i<NB_L; i++) {
for (j=0; j<NB_C; j++) {
DessineUneCaseDuLabyrinthe (mat, ecran, S,i,j) ;
}
}
}
/**************************************************************************************************/
void DessinPac (SDL_Surface * S [NB_L][NB_C],SDL_Surface * ecran, int l, int c, int key, int im)
{
SDL_Rect position ;
int i ;
int est_sur_monstre = 0 ;
for (i=0; i < NB_MONSTRES; i++) {
if (monstres [i][0] == l && monstres [i][1] == c) est_sur_monstre = 1 ;
}
if (est_sur_monstre != 1) {
char nom_image [24] ;
char car[4] = {'d','g','h','b'} ;
sprintf (nom_image, "IM/pac%c%d.bmp",car[key-1], im) ;
S[l][c] = SDL_LoadBMP (nom_image) ;
//SDL_SetColorKey (S[l][c], SDL_SRCCOLORKEY, SDL_MapRGB ( S[l][c] -> format, 255, 255, 255)) ;
position.x = c*TAILLE_CARRE ;
position.y = l*TAILLE_CARRE ;
SDL_BlitSurface (S[l][c], NULL, ecran, &position) ;
}
}
/**************************************************************************************************/
void PositionSuivPacman (int * l, int * c, Tableau2D mat, int key)
{
if (key == GAUCHE ) {
if (0 <= *c-1 && mat [*l][*c-1] != MUR) *c=*c-1;
}
else if (key == DROITE) {
if ( *c+1 < NB_C && mat [*l][*c+1] != MUR) *c=*c+1;
}
else if (key == HAUT) {
if ( 0 <= *l-1 && mat [*l-1][*c] != MUR) *l=*l-1;
}
else if (key == BAS) {
if ( *l+1 < NB_L && mat [*l+1][*c] != MUR) *l=*l+1;
}
}
/**************************************************************************************************/
int DeplacePacman (int * l, int * c, int * nbPoints, Tableau2D mat, SDL_Surface * ecran, SDL_Surface * S[NB_L][NB_C], int key,int im)
{
int lig, col ;
int val = 0 ;
lig = *l ;
col = *c ;
PositionSuivPacman (l, c, mat,key) ;
DessineUneCaseDuLabyrinthe (mat, ecran, S, lig, col) ;
if (mat [*l][*c] == POINT) {
nbPoints++ ;
mat [*l][*c] = VIDE ;
val = 1 ;
}
DessinPac (S, ecran, *l, *c, key,im) ;
return val ;
}
/**************************************************************************************************/
void PositionSuivMonstre (int *l, int *c, int *dir,int lp, int cp, Tableau2D mat)
{
int d ;
int EcartX = *c - cp ;
int EcartY = *l - lp ;
*l = *l + tabDirection[*dir][0] ;
*c = *c + tabDirection[*dir][1] ;
if (-DIST_MAX<=EcartX && EcartX < 0 && *l==lp && mat[*l+tabDirection[A_DROITE][0]][*c+tabDirection[A_DROITE][1]] != MUR)
{
*dir = A_DROITE ;
}
else if (0 < EcartX && EcartX <= DIST_MAX && *l==lp && mat[*l+tabDirection[A_GAUCHE][0]][*c+tabDirection[A_GAUCHE][1]] != MUR)
{
*dir = A_GAUCHE ;
}
else if (0 < EcartY && EcartY <= DIST_MAX && *c==cp && mat[*l+tabDirection[EN_HAUT][0]][*c+tabDirection[EN_HAUT][1]] != MUR)
{
*dir = EN_HAUT ;
}
else if (DIST_MAX <= EcartY && EcartY < 0 && *c==cp && mat[*l+tabDirection[EN_BAS][0]][*c+tabDirection[EN_BAS][1]] != MUR)
{
*dir = EN_BAS ;
}
else
{
while ((d=rand()%4) == (*dir+2)%4 || mat[*l+tabDirection[d][0]][*c+tabDirection[d][1]] == MUR) ;
*dir = d ;
}
}
/**************************************************************************************************/
void DessinMonstre (SDL_Surface * S [NB_L][NB_C],SDL_Surface * ecran, int l, int c, int im)
{
SDL_Rect position ;
char nom_image [24] ;
sprintf (nom_image, "IMM/mon%d.bmp", im) ;
S[l][c] = SDL_LoadBMP (nom_image) ;
//SDL_SetColorKey (S[l][c], SDL_SRCCOLORKEY, SDL_MapRGB ( S[l][c] -> format, 255, 255, 255)) ;
position.x = c*TAILLE_CARRE ;
position.y = l*TAILLE_CARRE ;
SDL_BlitSurface (S[l][c], NULL, ecran, &position) ;
}
/**************************************************************************************************/
void DessinMonstres \
(SDL_Surface * S [NB_L][NB_C], SDL_Surface * ecran, TableauMonstre monstres, int nbMonstres, int lp, int cp, Tableau2D mat, int im)
{
int i ;
for (i=0; i<3; i++) {
DessineUneCaseDuLabyrinthe (mat, ecran, S, monstres[i][0], monstres[i][1]) ;
PositionSuivMonstre (&monstres[i][0],&monstres[i][1], &monstres[i][2],lp, cp, mat);
DessinMonstre (S, ecran, monstres[i][0], monstres[i][1], im) ;
}
}
/**************************************************************************************************/
int MangerParlesMonstres (TableauMonstre monstres, int nbMonstres, int l, int c)
{
int i ;
for (i=0; i<nbMonstres; i++) {
if (monstres [i][0] == l && monstres [i][1] == c) return 1 ;
}
return 0 ;
} |
Partager