Jeu Class Reference

Classe permettant de gérer le jeu de pacman
Cette classe est un singleton, elle peut donc être utilisée par plusieurs thread en même temps. More...

#include <Jeu.h>

Inheritance diagram for Jeu:

Inheritance graph
[legend]
Collaboration diagram for Jeu:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool GameOver ()
 Savoir si la partie est terminée.
void KillGame ()
 Méthode permettant d'aborter la partie (Utilisée en cas de déconnexion de tous les clients).
bool DeplacerPersonnage (unsigned int codePerso, char sens)
 Méthode permettant de déplacement un personnage dans la grille.
void SetJoueur (unsigned int id, string login)
 Méthode permettant d'affecter un login à un personnage.
void UnSetJoueur (unsigned int id)
 Désassocier un joueur à un personnage (Cas de la déconnexion).
unsigned int GetScorePacman ()
unsigned int GetScoreF (unsigned int noFantome)
string GetLoginPacman ()
string GetLoginF (unsigned int noFantome)
bool GetPacmanConnecte ()
bool GetFConnecte (unsigned int noFantome)
void SetNbFantomeAuto (unsigned int nb)
unsigned int GetNbFantomeAuto ()
string JoueurConnectes () const
 Donne l'état de connection des joueurs 0 pour non connecté, 1 pour connecté.
string toString ()
 Méthode transformant la grille en string (Envoi sur le réseau).
string EtatPartie ()
 Méthode donnant l'état de la partie [loginP score loginF[0.
bool JeuPret () const
 Méthode indiquant que le jeu est prêt.
unsigned int UintAleat (unsigned int min, unsigned int max)

Private Member Functions

 Jeu ()
 ~Jeu ()
void ConstruireMur (unsigned int x, unsigned int y, unsigned int l, char sens)
 Méthode permettant de construire un mur (l'origine est en haut à gauche).
void SetPoint (unsigned int x, unsigned int y, char c)
 M2thode permettant modifier une case de la grille.
int PointLibre (unsigned int x, unsigned int y)
 Méthode permettant de connaitre l'état d'une case.
bool DeplacerPacman (char sens)
bool DeplacerFantome (unsigned int noFantome, char sens)
bool GetPacmanVivant ()
void Afficher () const

Private Attributes

char mGrille [20][20]
 Représentation de la grille.
int mNbFantomeAuto
 Nombre de fantomes automatiques de la partie.
Point mCoordPacman
 Coordonnées de Pacman.
unsigned int mScorePacman
 Score de Pacman.
bool mPacmanVivant
 Indique si Pacman est toujours vivant.
bool mJoueurPacman
 Indique si Pacman est connecté (login renseigné).
string mLoginPacman
 Login de Pacman.
Point mCoordF [3]
 Coordonnées des fantomes.
unsigned int mScoreF [3]
 Score des fantomes.
bool mJoueurF [3]
 Indique si les fantomes sont connectés (logins renseignés).
string mLoginF [3]
 Login des fantomes.
Point mCoordP [3]
 Coordonnées des pommes "mangées" par les fantomes lors du déplacement précédent afin de les replacer (-1,-1) si aucune.
unsigned int mNBPomme
 Nombre de pomme encore en jeu.
Mutex mVerrou
 Mutex pour gérer les zones critiques.

Friends

class Singleton< Jeu >

Detailed Description

Classe permettant de gérer le jeu de pacman
Cette classe est un singleton, elle peut donc être utilisée par plusieurs thread en même temps.


Les zones critiques sont protégés par un sémaphore d'exclusion mutuelle.

Definition at line 48 of file Jeu.h.


Constructor & Destructor Documentation

Jeu::Jeu (  )  [private]

Definition at line 29 of file Jeu.cpp.

References ConstruireMur(), mCoordF, mCoordPacman, mGrille, mJoueurF, mJoueurPacman, mNbFantomeAuto, mNBPomme, mPacmanVivant, mScoreF, mScorePacman, PointLibre(), SetPoint(), UintAleat(), Point::x, and Point::y.

00029         {
00030         mNbFantomeAuto=-1;
00031         //Initialisations des variables relatives aux joueurs 
00032         mJoueurPacman=false;
00033         for(unsigned int i=0; i<3; i++) mJoueurF[i]=false;
00034         
00035         //Initialisation des attributs de pacman
00036         mScorePacman=0;
00037         mPacmanVivant=true;
00038 
00039         //Initialisation de la grille
00040         Point coord;
00041         for(unsigned int i=0; i<20; i++){
00042                 for(unsigned int j=0; j<20; j++){
00043                         mGrille[i][j]='+';
00044                 }
00045         }
00046         //Construction des bordures
00047         ConstruireMur(0,0,20,'H');
00048         ConstruireMur(0,0,20,'V');
00049         ConstruireMur(0,19,20,'H');
00050         ConstruireMur(19,0,20,'V');     
00051         //Construction aléatoire de murs internes 
00052         char sens;
00053         for(unsigned int i=0; i<20; i++){
00054                 if(UintAleat(1,2)==1) sens='V'; //On détermine l'orientation à pile ou face
00055                 else sens='H';
00056                 ConstruireMur(UintAleat(0,19),UintAleat(0,19),UintAleat(0,5),sens);
00057         }
00058         unsigned int x,y;
00059         //On place 100 fruits
00060         mNBPomme=0;
00061         for(unsigned int i=0; i<100; i++){
00062                 do{
00063                         x=UintAleat(0,19); y=UintAleat(0,19);
00064                 } while(PointLibre(x,y)!=0); //Case non libre
00065                 SetPoint(x,y,'x');
00066                 mNBPomme++;
00067         }
00068         //On place 1 pacman 
00069         do{
00070                 x=UintAleat(0,19); y=UintAleat(0,19);
00071         } while(PointLibre(x,y)!=0); //Case non libre
00072         SetPoint(x,y,'P');
00073         coord.x=x; coord.y=y;
00074         mCoordPacman=coord;
00075         //On place 3 fantomes 
00076         for(unsigned int i=0; i<3; i++){
00077                 do{
00078                         x=UintAleat(0,19); y=UintAleat(0,19);
00079                 } while(PointLibre(x,y)!=0); //Case non libre
00080                 SetPoint(x,y,'F');
00081                 coord.x=x; coord.y=y;
00082                 mCoordF[i]=coord;
00083                 mScoreF[i]=0;
00084         }
00085 }

Here is the call graph for this function:

Jeu::~Jeu (  )  [private]

Definition at line 87 of file Jeu.cpp.

00087 {}


Member Function Documentation

bool Jeu::GameOver (  ) 

Savoir si la partie est terminée.

Returns:
Vrai si pacman a été tué ou s'il a mangé tous les fruits.

Definition at line 23 of file Jeu.cpp.

References mNBPomme, and mPacmanVivant.

Referenced by ServeurJeu::AttendreFinPartie(), TraitementJoueur::DeplacementAuto(), EtatPartie(), TraitementComServeurPrincipal::IndiquerStatusPartie(), and TraitementJoueur::TraitementDeplacement().

00023                   {
00024         if(!mPacmanVivant) return true;
00025         if(mNBPomme==0) return true;
00026         return false;
00027 }

void Jeu::KillGame (  )  [inline]

Méthode permettant d'aborter la partie (Utilisée en cas de déconnexion de tous les clients).

Definition at line 64 of file Jeu.h.

References mPacmanVivant.

Referenced by ServeurJeu::AttendreFinPartie().

00064 { mPacmanVivant=false; }        

bool Jeu::DeplacerPersonnage ( unsigned int  codePerso,
char  sens 
)

Méthode permettant de déplacement un personnage dans la grille.

Parameters:
codePerso Code du personnage: de 0 à 2 un fantome, 3 pour pacman.
sens H pour haut, B pour bas, G pour gauche et D pour droite.
Returns:
Vrai si le déplacement a eu lieu.

Definition at line 89 of file Jeu.cpp.

References DeplacerFantome(), and DeplacerPacman().

Referenced by TraitementJoueur::DeplacementAuto(), and TraitementJoueur::TraitementDeplacement().

00089                                                              {
00090         if(codePerso==3){
00091                 return DeplacerPacman(sens);
00092         } else if((codePerso>=0)&&(codePerso<=2)){
00093                 return DeplacerFantome(codePerso,sens);
00094         }
00095         return false;
00096 }

Here is the call graph for this function:

void Jeu::SetJoueur ( unsigned int  id,
string  login 
) [inline]

Méthode permettant d'affecter un login à un personnage.


Cela permet également de savoir quels joueurs sont connectés

Parameters:
id Code du personnage: de 0 à 2 un fantome, 3 pour pacman.
login Login du joueur.

Definition at line 80 of file Jeu.h.

References mJoueurF, mJoueurPacman, mLoginF, and mLoginPacman.

Referenced by TraitementJoueur::Traitement(), and TraitementJoueur::WaitForRole().

00080                                                      { 
00081                 if(id==3) {
00082                         mJoueurPacman=true;     
00083                         mLoginPacman=login; 
00084                 } else {
00085                         mJoueurF[id]=true;
00086                         mLoginF[id]=login;
00087                 }
00088         }

void Jeu::UnSetJoueur ( unsigned int  id  )  [inline]

Désassocier un joueur à un personnage (Cas de la déconnexion).

Parameters:
id Code du personnage déconnecté: de 0 à 2 un fantome, 3 pour pacman.

Definition at line 94 of file Jeu.h.

References mJoueurF, and mJoueurPacman.

Referenced by TraitementJoueur::ModeZombie().

00094                                          { 
00095                 if(id==3) mJoueurPacman=false;  
00096                 else mJoueurF[id]=false;
00097         }

unsigned int Jeu::GetScorePacman (  )  [inline]

Definition at line 99 of file Jeu.h.

References mScorePacman.

00099 { return mScorePacman; }

unsigned int Jeu::GetScoreF ( unsigned int  noFantome  )  [inline]

Definition at line 100 of file Jeu.h.

References mScoreF.

00100 { return mScoreF[noFantome];}

string Jeu::GetLoginPacman (  )  [inline]

Definition at line 101 of file Jeu.h.

References mLoginPacman.

Referenced by TraitementComServeurPrincipal::IndiquerConnexions().

00101 { return mLoginPacman; }

string Jeu::GetLoginF ( unsigned int  noFantome  )  [inline]

Definition at line 102 of file Jeu.h.

References mLoginF.

Referenced by TraitementComServeurPrincipal::IndiquerConnexions().

00102 { return mLoginF[noFantome];}

bool Jeu::GetPacmanConnecte (  )  [inline]

Definition at line 104 of file Jeu.h.

References mJoueurPacman.

Referenced by TraitementComServeurPrincipal::IndiquerConnexions().

00104 { return mJoueurPacman; }

bool Jeu::GetFConnecte ( unsigned int  noFantome  )  [inline]

Definition at line 105 of file Jeu.h.

References mJoueurF.

Referenced by TraitementComServeurPrincipal::IndiquerConnexions().

00105 { return mJoueurF[noFantome]; }

void Jeu::SetNbFantomeAuto ( unsigned int  nb  )  [inline]

Definition at line 107 of file Jeu.h.

References mNbFantomeAuto.

Referenced by ServeurJeu::ServeurJeu().

00107 { mNbFantomeAuto=nb; }

unsigned int Jeu::GetNbFantomeAuto (  )  [inline]

Definition at line 108 of file Jeu.h.

References mNbFantomeAuto.

Referenced by TraitementComServeurPrincipal::IndiquerAttenteJoueurs(), and ServeurJeu::ServeurJeu().

00108 { return mNbFantomeAuto;}

string Jeu::JoueurConnectes (  )  const

Donne l'état de connection des joueurs 0 pour non connecté, 1 pour connecté.

Returns:
[0|1][0|1][0|1][0|1] (Pacman, Fantome1, Fantome2, Fantome3)

Definition at line 256 of file Jeu.cpp.

References mJoueurF, and mJoueurPacman.

Referenced by TraitementJoueur::Traitement(), and TraitementJoueur::WaitForRole().

00256                                  {
00257         string res="";
00258         for(unsigned int i=0; i<3; i++) {
00259                 if(mJoueurF[i]) res+='1';
00260                 else res+='0';
00261         }
00262         if(mJoueurPacman) res+='1';
00263         else res+='0';
00264         return res;
00265 }

string Jeu::toString (  ) 

Méthode transformant la grille en string (Envoi sur le réseau).

Returns:

Definition at line 267 of file Jeu.cpp.

References Mutex::Lock(), mGrille, mVerrou, and Mutex::Unlock().

Referenced by TraitementJoueur::TraitementDeplacement().

00267                     {
00268         mVerrou.Lock();
00269         string res="";
00270         for(unsigned int i=0; i<20; i++){
00271                 for(unsigned int j=0; j<20; j++){
00272                         res+=mGrille[i][j];
00273                 }
00274         }       
00275         mVerrou.Unlock();
00276         return res;
00277 }

Here is the call graph for this function:

string Jeu::EtatPartie (  ) 

Méthode donnant l'état de la partie [loginP score loginF[0.

.2] scoreF[0..2] NombreDePommesRestantes GAMEOK | GAMEOVER ] (Envoi sur le réseau)

Returns:

Definition at line 279 of file Jeu.cpp.

References GameOver(), mLoginF, mLoginPacman, mNBPomme, mScoreF, and mScorePacman.

Referenced by TraitementComServeurPrincipal::IndiquerFinPartie(), TraitementComServeurPrincipal::IndiquerStatusPartie(), and TraitementJoueur::TraitementDeplacement().

00279                       {
00280 //mLoginPacman mScorePacman mLoginF mScoreF mNBPomme status
00281         string etat="";
00282         etat+=mLoginPacman; etat+=" ";
00283         ostringstream ossScoreP;
00284         ossScoreP<<mScorePacman;
00285         etat+=ossScoreP.str(); etat+=" ";
00286         for(unsigned int i=0; i<3; i++){
00287                 etat+=mLoginF[i]; etat+=" ";
00288                 ostringstream ossScore;
00289                 ossScore<<mScoreF[i];
00290                 etat+=ossScore.str(); etat+=" ";
00291         }
00292         ostringstream ossPomme;
00293         ossPomme<<mNBPomme;
00294         etat+=ossPomme.str(); etat+=" ";
00295         if(GameOver()) etat+="GAMEOVER";
00296         else etat+="GAMEOK";
00297         return etat;
00298         
00299 }

Here is the call graph for this function:

bool Jeu::JeuPret (  )  const

Méthode indiquant que le jeu est prêt.

Returns:
Vrai si tous les joueurs sont connectés

Definition at line 301 of file Jeu.cpp.

References mJoueurF, and mJoueurPacman.

Referenced by ServeurJeu::AttendreDebutPartie(), and TraitementJoueur::WaitForPlayers().

00301                        {
00302         if((mJoueurPacman)&&(mJoueurF[0])&&(mJoueurF[1])&&(mJoueurF[2])) return true;
00303         return false;
00304 }

unsigned int Jeu::UintAleat ( unsigned int  min,
unsigned int  max 
)

Definition at line 306 of file Jeu.cpp.

Referenced by TraitementJoueur::DeplacementAuto(), and Jeu().

00306                                                              {
00307         static bool first=true;
00308         //On initialise le générateur en fonction de l'horloge
00309         if(first) {
00310                 srand((unsigned)time(NULL));
00311                 first=false;
00312         }
00313         unsigned int nb=(unsigned)rand();
00314         //on tire un nombre au hasard et on le place sur le bon intervalle.
00315         unsigned int final=(unsigned int)(min+((float)rand()/RAND_MAX*(max)));
00316         if(final==0) return 1;
00317         return final;
00318 }

void Jeu::ConstruireMur ( unsigned int  x,
unsigned int  y,
unsigned int  l,
char  sens 
) [private]

Méthode permettant de construire un mur (l'origine est en haut à gauche).

Parameters:
x Abscisse d'origine
y Ordonnée d'origine
l Longeur du mur à construire
sens Sens de construction V pour vertical, H pour horizontal

Definition at line 235 of file Jeu.cpp.

References SetPoint().

Referenced by Jeu().

00235                                                                              {
00236         unsigned int i;
00237         if(s=='V'){
00238                 //De x,y vers le bas (x reste fixe, on incrémente y)
00239                 for(i=y; i<=y+l; i++) SetPoint(x,i,'I');
00240         } else {
00241                 //De x,y vers la droite (on incrémente x, y reste fixe)
00242                 for(i=x; i<=x+l; i++) SetPoint(i,y,'I');
00243         }
00244 }

Here is the call graph for this function:

void Jeu::SetPoint ( unsigned int  x,
unsigned int  y,
char  c 
) [private]

M2thode permettant modifier une case de la grille.

En exclusion mutuelle avec PointLibre

Parameters:
x Abscisse
y Ordonnée
c Nouvelle valeur

Definition at line 246 of file Jeu.cpp.

References Mutex::Lock(), mGrille, mVerrou, and Mutex::Unlock().

Referenced by ConstruireMur(), DeplacerFantome(), DeplacerPacman(), and Jeu().

00246                                                         {
00247         mVerrou.Lock();
00248         if((x>=0)&&(x<20)){
00249                 if((y>=0)&&(y<20)){
00250                         mGrille[y][x]=c;
00251                 }
00252         }
00253         mVerrou.Unlock();       
00254 }

Here is the call graph for this function:

int Jeu::PointLibre ( unsigned int  x,
unsigned int  y 
) [private]

Méthode permettant de connaitre l'état d'une case.

En exclusion mutuelle avec SetPoint

Parameters:
x Abscisse
y Ordonnée
Returns:
0 vide, 1 fruit, 2 pacman, 3 fantome, 4 mur.

Definition at line 351 of file Jeu.cpp.

References Mutex::Lock(), mGrille, mVerrou, and Mutex::Unlock().

Referenced by DeplacerFantome(), DeplacerPacman(), and Jeu().

00351                                                   {
00352         mVerrou.Lock();
00353         if((x>=0)&&(x<20)){
00354                 if((y>=0)&&(y<20)){
00355                         switch(mGrille[y][x]){
00356                                 case '+' : { mVerrou.Unlock(); return 0; } //Case vide
00357                                 case 'x' : { mVerrou.Unlock(); return 1; } //Occupée par un fruit
00358                                 case 'P' : { mVerrou.Unlock(); return 2; } //Occupée par Pacman
00359                                 case 'F' : { mVerrou.Unlock(); return 3; } //Occupée par un fantôme
00360                                 case 'I' : { mVerrou.Unlock(); return 4; } //Occupée par un mur
00361                                 default : { mVerrou.Unlock(); return -1; }
00362                         }
00363                 }
00364         }
00365         mVerrou.Unlock();
00366         return -1;
00367 }

Here is the call graph for this function:

bool Jeu::DeplacerPacman ( char  sens  )  [private]

Definition at line 98 of file Jeu.cpp.

References mCoordPacman, mNBPomme, mPacmanVivant, mScorePacman, PointLibre(), SetPoint(), Point::x, and Point::y.

Referenced by DeplacerPersonnage().

00098                                  {
00099         unsigned int newX, newY;
00100         switch(sens){
00101                 case 'G' : {
00102                         newX=mCoordPacman.x-1; newY=mCoordPacman.y;
00103                         break;
00104                 }
00105                 case 'D' : {
00106                         newX=mCoordPacman.x+1; newY=mCoordPacman.y;
00107                         break;
00108                 }
00109                 case 'H' : {
00110                         newX=mCoordPacman.x; newY=mCoordPacman.y-1;
00111                         break;
00112                 }
00113                 case 'B' : {
00114                         newX=mCoordPacman.x; newY=mCoordPacman.y+1;
00115                         break;
00116                 }
00117         }
00118         switch(PointLibre(newX,newY)){
00119                 case -1 : { //Mouvement hors plateau
00120                         //Pas de déplacement
00121                         return false;
00122                 }
00123                 case 0 : {  //Case vide
00124                         SetPoint(mCoordPacman.x,mCoordPacman.y,'+');
00125                         mCoordPacman.x=newX; mCoordPacman.y=newY;
00126                         SetPoint(mCoordPacman.x,mCoordPacman.y,'P');
00127                         return true;
00128                 }
00129                 case 1 : { //Occupée par un fruit
00130                         SetPoint(mCoordPacman.x,mCoordPacman.y,'+');
00131                         mCoordPacman.x=newX; mCoordPacman.y=newY;
00132                         SetPoint(mCoordPacman.x,mCoordPacman.y,'P');
00133                         mScorePacman++;
00134                         mNBPomme--;
00135                         return true;
00136                 }
00137                 //case 2 impossible (pacman n'a pas le don d'ubiquité :=)
00138 
00139                 case 3 : { //Occupée par un fantôme
00140                         //On efface le pauvre pacman
00141                         SetPoint(mCoordPacman.x,mCoordPacman.y,'+');
00142                         mPacmanVivant=false;
00143                         return false;
00144                 }
00145                 case 4 : { //Occupée par un mur
00146                         //Pas de déplacement
00147                         return false;
00148                 }
00149         }               
00150 }

Here is the call graph for this function:

bool Jeu::DeplacerFantome ( unsigned int  noFantome,
char  sens 
) [private]

Definition at line 152 of file Jeu.cpp.

References mCoordF, mCoordP, mPacmanVivant, mScoreF, mVerrou, PointLibre(), SetPoint(), Mutex::Unlock(), Point::x, and Point::y.

Referenced by DeplacerPersonnage().

00152                                                           {
00153         unsigned int newX, newY;
00154         switch(sens){
00155                 case 'G' : {
00156                         newX=mCoordF[noFantome].x-1; newY=mCoordF[noFantome].y;
00157                         break;
00158                 }
00159                 case 'D' : {
00160                         newX=mCoordF[noFantome].x+1; newY=mCoordF[noFantome].y;
00161                         break;
00162                 }
00163                 case 'H' : {
00164                         newX=mCoordF[noFantome].x; newY=mCoordF[noFantome].y-1;
00165                         break;
00166                 }
00167                 case 'B' : {
00168                         newX=mCoordF[noFantome].x; newY=mCoordF[noFantome].y+1;
00169                         break;
00170                 }
00171         }
00172         switch(PointLibre(newX,newY)){
00173                 case -1 : { //Mouvement hors plateau
00174                         //Pas de déplacement
00175                         mVerrou.Unlock();
00176                         return false;
00177                 }
00178                 case 0 : {  //Case vide
00179                         //On efface la case sur laquelle était le fantome
00180                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'+');
00181                         //Si on a en mémoire les coordonées d'un fruit, on le replace sur la grille 
00182                         if((mCoordP[noFantome].x!=-1)&&(mCoordP[noFantome].y!=-1)) SetPoint(mCoordP[noFantome].x,mCoordP[noFantome].y,'x');
00183                         //On déplace le fantome
00184                         mCoordF[noFantome].x=newX; mCoordF[noFantome].y=newY;
00185                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'F');
00186                         //On indique que le fantome n'a pas écrasé de fruit 
00187                         mCoordP[noFantome].x=-1; mCoordP[noFantome].y=-1;
00188                         mVerrou.Unlock();
00189                         return true;
00190                 }
00191                 case 1 : { //Occupée par un fruit
00192                         //On efface la case sur laquelle était le fantome
00193                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'+');
00194                         //Si on a en mémoire les coordonées d'un fruit, on le replace sur la grille 
00195                         if((mCoordP[noFantome].x!=-1)&&(mCoordP[noFantome].y!=-1)) SetPoint(mCoordP[noFantome].x,mCoordP[noFantome].y,'x');
00196                         //On place le fantome à la nouvelle position ce faisant on efface un fruit
00197                         mCoordF[noFantome].x=newX; mCoordF[noFantome].y=newY;
00198                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'F');
00199                         //Mais on le garde en mémoire afin de le replacer ultérieurement
00200                         mCoordP[noFantome].x=newX; mCoordP[noFantome].y=newY;
00201                         mVerrou.Unlock();
00202                         return true;
00203                 }
00204                 case 2 : { //Occupée par pacman
00205                         //On efface la case sur laquelle était le fantome
00206                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'+');
00207                         //Si on a en mémoire les coordonées d'un fruit, on le replace sur la grille 
00208                         if((mCoordP[noFantome].x!=-1)&&(mCoordP[noFantome].y!=-1)) SetPoint(mCoordP[noFantome].x,mCoordP[noFantome].y,'x');
00209                         //On déplace le fantome
00210                         mCoordF[noFantome].x=newX; mCoordF[noFantome].y=newY;
00211                         SetPoint(mCoordF[noFantome].x,mCoordF[noFantome].y,'F');
00212                         //Pour pacman c'est la fin...
00213                         mScoreF[noFantome]+=10;
00214                         mPacmanVivant=false;
00215                         //On indique que le fantome n'a pas écrasé de fruit (par pure conscience professionelle hein)
00216                         mCoordP[noFantome].x=-1; mCoordP[noFantome].y=-1;
00217                         mVerrou.Unlock();
00218                         return true;
00219                 }
00220                 case 3 : { //Occupée par un fantôme
00221                         //Pas de déplacement
00222                         mVerrou.Unlock();
00223                         return false;
00224                 }
00225                 case 4 : { //Occupée par un mur
00226                         //Pas de déplacement
00227                         mVerrou.Unlock();
00228                         return false;
00229                 }
00230         }
00231         
00232 }

Here is the call graph for this function:

bool Jeu::GetPacmanVivant (  )  [inline, private]

Definition at line 164 of file Jeu.h.

References mPacmanVivant.

00164 { return mPacmanVivant; }

void Jeu::Afficher (  )  const [private]

Definition at line 320 of file Jeu.cpp.

References mGrille, and mScorePacman.

00320                         {
00321         for(unsigned int i=0; i<20; i++){
00322                 for(unsigned int j=0; j<20; j++){
00323                         switch(mGrille[i][j]){
00324                                 case '+' : {
00325                                         printf( "\e[30;47m%c \e[m",mGrille[i][j]);
00326                                         break;
00327                                 }
00328                                 case 'x' : {
00329                                         printf( "\e[30;47m\e[33m%c \e[m\e[m",mGrille[i][j]);
00330                                         break;
00331                                 }
00332                                 case 'P' : {
00333                                         printf( "\e[30;47m\e[34m%c \e[m\e[m",mGrille[i][j]);
00334                                         break;
00335                                 }
00336                                 case 'F' : {
00337                                         printf( "\e[30;47m\e[31m%c \e[m\e[m",mGrille[i][j]);
00338                                         break;
00339                                 }
00340                                 case 'I' : {
00341                                         printf( "\e[30;47m%c \e[m",mGrille[i][j]);
00342                                         break;
00343                                 }
00344                         }               
00345                 }
00346                 if(i==0) printf( "  \e[30;47m Score Pacman \e[31m%d \e[m\e[m\n",mScorePacman);
00347                 else cout<<endl;
00348         }       
00349 }


Friends And Related Function Documentation

friend class Singleton< Jeu > [friend]

Definition at line 49 of file Jeu.h.


Member Data Documentation

char Jeu::mGrille[20][20] [private]

Représentation de la grille.

Definition at line 170 of file Jeu.h.

Referenced by Afficher(), Jeu(), PointLibre(), SetPoint(), and toString().

int Jeu::mNbFantomeAuto [private]

Nombre de fantomes automatiques de la partie.

Definition at line 175 of file Jeu.h.

Referenced by GetNbFantomeAuto(), Jeu(), and SetNbFantomeAuto().

Point Jeu::mCoordPacman [private]

Coordonnées de Pacman.

Definition at line 181 of file Jeu.h.

Referenced by DeplacerPacman(), and Jeu().

unsigned int Jeu::mScorePacman [private]

Score de Pacman.

Definition at line 186 of file Jeu.h.

Referenced by Afficher(), DeplacerPacman(), EtatPartie(), GetScorePacman(), and Jeu().

bool Jeu::mPacmanVivant [private]

Indique si Pacman est toujours vivant.

Definition at line 191 of file Jeu.h.

Referenced by DeplacerFantome(), DeplacerPacman(), GameOver(), GetPacmanVivant(), Jeu(), and KillGame().

bool Jeu::mJoueurPacman [private]

Indique si Pacman est connecté (login renseigné).

Definition at line 196 of file Jeu.h.

Referenced by GetPacmanConnecte(), Jeu(), JeuPret(), JoueurConnectes(), SetJoueur(), and UnSetJoueur().

string Jeu::mLoginPacman [private]

Login de Pacman.

Definition at line 201 of file Jeu.h.

Referenced by EtatPartie(), GetLoginPacman(), and SetJoueur().

Point Jeu::mCoordF[3] [private]

Coordonnées des fantomes.

Definition at line 207 of file Jeu.h.

Referenced by DeplacerFantome(), and Jeu().

unsigned int Jeu::mScoreF[3] [private]

Score des fantomes.

Definition at line 212 of file Jeu.h.

Referenced by DeplacerFantome(), EtatPartie(), GetScoreF(), and Jeu().

bool Jeu::mJoueurF[3] [private]

Indique si les fantomes sont connectés (logins renseignés).

Definition at line 217 of file Jeu.h.

Referenced by GetFConnecte(), Jeu(), JeuPret(), JoueurConnectes(), SetJoueur(), and UnSetJoueur().

string Jeu::mLoginF[3] [private]

Login des fantomes.

Definition at line 222 of file Jeu.h.

Referenced by EtatPartie(), GetLoginF(), and SetJoueur().

Point Jeu::mCoordP[3] [private]

Coordonnées des pommes "mangées" par les fantomes lors du déplacement précédent afin de les replacer (-1,-1) si aucune.

Definition at line 228 of file Jeu.h.

Referenced by DeplacerFantome().

unsigned int Jeu::mNBPomme [private]

Nombre de pomme encore en jeu.

Definition at line 233 of file Jeu.h.

Referenced by DeplacerPacman(), EtatPartie(), GameOver(), and Jeu().

Mutex Jeu::mVerrou [private]

Mutex pour gérer les zones critiques.

Definition at line 238 of file Jeu.h.

Referenced by DeplacerFantome(), PointLibre(), SetPoint(), and toString().


The documentation for this class was generated from the following files:
Generated on Wed Jan 2 14:02:04 2008 for Pacman by  doxygen 1.5.1