Jeu d'echec tymulus modifié par mélanie gagné

Contenu du snippet

J'ai fait ce projet de modifier ce code au cours de mon cours de Correction de programme avec monsieur Jean Lemay.

Voici les buts que j`avais a atteindre:

Ajout d'un score
Ajoute d'un Chronomètre
se déplacer vers la mise en echec impossible(FAIT
option de changement de couleur(possible, mais aucun bouton réussi a mettre pour le faire ... donc tout dépend de où vous cliquer)
revoir les avertissements d'echec et math pour verifier leur validitée(FAIT)
le faire réussir a compiler sous visual studio 2003(FAIT)


Le lien de l'original: http://www.cppfrance.com/codes/JEU-ECHECS-THYMULUS_27036.aspx

Source / Exemple :

//** Utilisez les fichiers de base à l'adresse http://www.cppfrance.com/codes/JEU-ECHECS-THYMULUS_27036.aspx
//** Puis remplacez WCGcore v0.7.cpp par le code suivant
                                  ///////Thym's Winchessgame////////
        /////////////////////////////////////////////////////////////////////////////////////////
    ///    T    ///  //  /////  //  ////            ////   ///   ///   //////   ///   ///        ///
       ////  //////  //  /////  /  ////   //   //   ////   ///   /// L //////   ///   ///   /////
       ////  //////  H   /////  Y//////   // M //   ////   ///   ///   //////   ///   ///   S  //
       ////  //////  //  /////  ///////   //   //   ////         ///      ///         //////   //
       ////  //////  //  ////  ////////   ///////   ////    U    ///      ///    U    ///	   //
       /////////////////////////////////////////////////////////////////////////////////////////
    
    /*
    
    Nom du programme        : Thym's Winchessgame
    Créateur et programmeur : Marc-Antoine Cottard   (m_a_cottard@hotmailcom)
    Testeur et graphiste    : Sylvain Héron
	Modificateur du programme: Mélanie Gagné (anouka_neandhal@hotmail.com)
	Modification effectuées le:	16 avril 2007 au ...
*********************************************************************************
		Ajouts à faire: Score, Temps écoulé, vérification des mises en
						échecs, Option de changement de couleur de la grille
						Déplacement vers la mise en échec impossible
*********************************************************************************
    --// Moteur du jeu //--
    
    ---- Historique ----
    Version 0.65  : Inclusion des roques
       cc1   : Correction bug du aux échecs
       cc2   : Amélioration de l'interface de sélection
       cc3   : Inclusion d'une IA de test
       cc4   : Allègement du code et optimisation
       cc5   : Correction bug IA
	   
    ---- Prochaine version ---
    Version 0.66  : Prise en passant du pion
    Version 0.75  : Fonction d'I.A.
    Version 0.85  : Fonction LAN
    
    --// Interface //--
    
    ---- Historique ----
    Version 0.11  : Messages en cas d'Eches & Mat
    
    ------------------------------------------------------------------------------------
    */
    
    
    
    
    //// Librairies
    #include <windows.h>
    #include <stdio.h>
    #include "Thymulus.h"
	
	#include <iostream>	

	using namespace std;
    
    //// Variables du moteur de jeu
    char temp, temc, Ntemc,Ppromotion='D';
    int xinit,xfinal,yinit,yfinal,x,y,compteurdemicoup=1,c=0,couleurajouer,testverifdeplac=1,testnonpiece=1,testverifcouleur=1,testpouvoirdeplac=1,testverifechec=0,RBdeplac=0,RNdeplac=0,TB0deplac=0,TB7deplac=0,TN0deplac=0,TN7deplac=0;
    char couleur[8][8] = {{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ',' ','B','B'},{'N','N',' ',' ',' ','B','B','B'}};
    char echiquier[8][8] = {{'T','p',' ',' ',' ',' ','p','T'},{'C','p',' ',' ',' ',' ','p','C'},{'F','p',' ',' ',' ',' ','p','F'},{'D','p',' ',' ',' ',' ','p','D'},{'R','p',' ',' ',' ',' ','p','R'},{'F','p',' ',' ',' ',' ','p','F'},{'C','p',' ',' ',' ',' ','p','C'},{'T','p',' ',' ',' ','v','p','T'}};
    char progress[8][8];
    char mat_progress[8][8];
    char mat_echiquier[8][8];
    char mat_couleur[8][8];
    char echec_progress[8][8];
    char mat2_couleur[8][8] ;
    char mat2_echiquier[8][8];
    char mat2_progress[8][8];
	char boutons[3];
    ////Variables de l'interface Thym's Win32API
    int xselec,yselec,xselec2,yselec2;
    int testselectcase = 0;
    char buf[256];
    PAINTSTRUCT ps; HDC hdc; RECT rc;
    HINSTANCE hInstance,hInstance2;
    HBITMAP hBmpRoi,hBmpDame,hBmpFou,hBmpCavalier,hBmpTour,hBmpPion,bttnPgnBleu,bttnPngVert,bttnPngRouge;
    HDC hdcMemRoi,hdcMemDame,hdcMemFou,hdcMemCavalier,hdcMemTour,hdcMemPion, hdcVert, hdcBleu, hdcRouge;
	int colorer =0;
    //// Variables de l'IA
    char temp2, temc2, Ntemc2;
    int testverifmat=0;
    int xai,yai,xai2,yai2,xai3,yai3,xai4,yai4;
    int eval1 = -50000;
    int eval2;
    HBRUSH Casesviolettes = CreateSolidBrush(RGB(200,50,100)); // brosse
	HBRUSH Casesgrises = CreateSolidBrush(RGB(225, 136, 182)); // brosse
          
    //// Fonctions du moteur de jeu ////
    void initMAT() {           // Initialise les matrices n°1
    copitab(mat_couleur,couleur);
    copitab(mat_echiquier,echiquier);
    copitab(mat_progress,progress); }
    // Initialise les matrices n°2
    void initMAT2(){           
    copitab(mat2_couleur,couleur);
    copitab(mat2_echiquier,echiquier);
    copitab(mat2_progress,progress); }
     // Initialise l'opposée de la variable couleur
    void initNtemc()
	{           
		if (temc == 'N') Ntemc = 'B';
		else Ntemc = 'N';
	}
    
     // Fonction du test de la possibilité de déplacement
    void pouvoirdeplac()
	{     
	 testpouvoirdeplac = 1;
	 for(y = 0; y < 8; y++)
       {
		for(x = 0; x < 8; x++)
         {
			 if (progress[x][y] == '*') testpouvoirdeplac = 0;
		 }
	   }
	}
   
    
    // Cherche toutes les possibilités de déplacement d'une pièce
    void possdedeplac(int xx,int yy)
	{  
		int x0,y0;    
		char tempc2 =' ';
		temp2 = echiquier[xx][yy];
		temc2 = couleur[xx][yy];    
	    
		for (x=0; x<8;x++)
		{
			if  (c==0 && couleurajouer == 0 && couleur[x][2] == 'N' && echiquier[x][2] == 'P') couleur[x][2] = ' ' , echiquier[x][2] = ' ';
				if  (c==0 && couleurajouer != 0 && couleur[x][5] == 'B' && echiquier[x][5] == 'P') couleur[x][5] = ' ' ,echiquier[x][5] = ' ';
		}
	      
		for(y0 = 0; y0 < 8; y0++)
		{
			for(x0 = 0; x0 < 8; x0++)
			{
				switch (temp2)
				{
					case 'T':
						if (xx != x0 && yy != y0)
							{ progress[x0][y0] =  ' ';}
						else progress[x0][y0] =  '+';
					break;
	                      
					case 'p':
						if (temc2 == 'B')
						{
							if ( yy != 6 )
							{
								if (xx  != x0 || y0 < (yy - 1) || y0 > yy)
								{
									progress[x0][y0] =  ' ';
								}
								else progress[x0][y0] = '+';
							}
							else
							{
								if (xx  != x0 || y0 < (yy - 2) || y0 > yy)
								{
									progress[x0][y0] =  ' '; 
								}
								else progress[x0][y0] =  '+';
							}
							break;
						}                              
						else
						{
							if ( yy != 1 )
							{
								if (xx  != x0 || y0 > (yy + 1) || y0 < yy)
								{
									progress[x0][y0] =  ' ';
								}
								else progress[x0][y0] = '+';
							}
							else
							{
								if (xx  != x0 || y0 > (yy + 2) || y0 < yy)
								{
									progress[x0][y0] =  ' '; 
								}
								else progress[x0][y0] =  '+';
							}
								break;
						}    
					break;
	                          
					case 'C':
						if ( (abs(x0 - xx) + abs(y0 - yy) == 3 ) && ((abs(x0 - xx) != 3 )) && ((abs(y0 - yy) != 3 )))
						{
							progress[x0][y0] =  '*'; 
						}
						else progress[x0][y0] =  ' ';
					break;
	                      
					case 'F':
						if ( abs(y0  - yy) != abs(x0 - xx) )
						{
							progress[x0][y0] =  ' '; 
						}
						else progress[x0][y0] =  '+';
					break;
	                      
					case 'R':
						if (abs(x0-xx) > 1 || abs(y0-yy) > 1 )
						{
							progress[x0][y0] =  ' '; 
						}
						else progress[x0][y0] =  '*';
					break;
	                      
					case 'D':
						if ((abs(y0  - yy) != abs(x0 - xx)) && (xx != x0 && yy != y0))
						{
							progress[x0][y0] =  ' '; 
						}
						else progress[x0][y0] =  '+';
					break;
				}
	                                              
	                                  
				if (couleur[x0][y0] == temc2 ) progress[x0][y0] = ' ';
				if (couleur[x0][y0] != ' ' && couleur[x0][y0] != temc2 )
				{
					if (progress [x0][y0] != '*' && echiquier[x0][y0] == 'R') progress [x0][y0] = '!';                 
					else if (progress [x0][y0] != '*') progress [x0][y0] = 'X';
				}
			}
		}
	   
		x0 = xx;
		y0 = yy;
		if (temp2 == 'p' && temc2 == 'N') tempc2 = 'l';
		if (temp2 == 'p' && temc2 == 'B') tempc2 = 'm';
	    
		xx = xx-1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress[xx][yy] = '*';
			xx = xx - 1;
		}
		if ( temp2 != 'C' && temp2 != 'F' && temp2 != 'p' && xx < 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		xx = x0;
		yy = yy -1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress[xx][yy] = '*';
			yy = yy - 1;
		}
		if (temp2 != 'C' && temp2 != 'F' && temp2 != 'p' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		yy = y0;
	    
		xx = xx + 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress [xx][yy] = '*';
			xx = xx + 1;
		}
		if (temp2 != 'C' && temp2 != 'F' && temp2 != 'p' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		xx = x0;
	    
		yy = yy + 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress[xx][yy] = '*';
			yy = yy + 1;
		}
		if (temp2 != 'C' && temp2 != 'F' && temp2 != 'p' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		yy = y0;
	    
		xx = xx + 1;
		yy = yy + 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress [xx][yy] = '*';
			xx = xx + 1;
			yy = yy + 1;
		}
		if (temp2 != 'C' && temp2 != 'T' && tempc2 != 'm' && xx< 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		xx = x0;
		yy = y0;
	    
		xx = xx - 1;
		yy = yy + 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress [xx][yy] = '*';
			xx = xx - 1;
			yy = yy + 1;
		}
		if (temp2 != 'C' && temp2 != 'T' && tempc2 != 'm' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 &&(progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		xx = x0;
		yy = y0;
	    
		xx = xx - 1;
		yy = yy - 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress [xx][yy] = '*';
			xx = xx - 1;
			yy = yy - 1;
		}
		if (temp2 != 'C' && temp2 != 'T' && tempc2 != 'l' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 &&(progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';
		xx = x0;
		yy = y0;
	    
		xx = xx + 1;
		yy = yy - 1;
		while (xx < 8 && xx > -1 && yy < 8 && yy > -1 && progress[xx][yy]=='+')
		{
			progress [xx][yy] = '*';
			xx = xx + 1;
			yy = yy - 1;
		}    
		if (temp2 != 'C' && temp2 != 'T' && tempc2 != 'l' &&  xx < 8 && xx > -1 && yy < 8 && yy > -1 && (progress[xx][yy]=='X'||progress[xx][yy]=='!')) progress[xx][yy]='*';       
		xx = x0;
		yy = y0;
	        
    }
    
    
  // Test la validité du déplacement
    void verifdeplac()  
    {
		testverifdeplac = 1;
		if (progress[xfinal][yfinal] == '*'||progress[xfinal][yfinal] == 'R') testverifdeplac = 0;
		if (couleur[xfinal][yfinal] == temc) testverifdeplac =2;
	}
    
    
    
    void verifcouleur()
    {
		testverifcouleur = 0;
		couleurajouer = compteurdemicoup % 2;
		switch (temc)
    {
    
    case 'N':
    if (couleurajouer == 0) testverifcouleur = 0;
    else testverifcouleur = 1;
    break;
    case 'B':
    if (couleurajouer == 0) testverifcouleur = 1;
    else testverifcouleur = 0;
    break;
    case ' ' : testverifcouleur = 1;
    }}
    
    // Vérifie les échecs
    void verifechec(char color)  
    {
		initNtemc();
		//echec_couleur = couleur ;
		copitab(echec_progress,progress) ;
		int xechec,yechec,xechec2,yechec2;
		int temtestverifechec;
		temtestverifechec = 1;
		testverifechec = 0;
		for(yechec = 0; yechec < 8; yechec++)
		{
			for(xechec = 0; xechec < 8; xechec++)
			{
				if (couleur[xechec][yechec] == color) 
				{
					possdedeplac(xechec,yechec);
					temtestverifechec = 1;
					for(yechec2 = 0; yechec2 < 8; yechec2++)
					{
						for(xechec2 = 0; xechec2 < 8; xechec2++)
						{
							if (progress[xechec2][yechec2] == '!') temtestverifechec = 0;
						}
					}
					if (temtestverifechec == 1) testverifechec = 1;
				}
			}
		}
		copitab(progress,echec_progress);
    }
    // Vérifie les mats
    void verifmat(HWND hwnd)  
    {
		initMAT();
		int xmat,ymat,xmat2,ymat2;
		verifechec(temc);
		int testverifmat;
		testverifmat =1;
		if (testverifechec == 1)
		{
			for(ymat = 0; ymat < 8; ymat++)
			{
				for(xmat = 0; xmat < 8; xmat++)
				{
					if (mat_couleur[xmat][ymat] == Ntemc)
					{
						possdedeplac(xmat,ymat);
	    
						for(ymat2 = 0; ymat2 < 8; ymat2++)
						{
							for(xmat2 = 0; xmat2 < 8; xmat2++)
							{
								if (progress[xmat2][ymat2] == '*') 
								{
									echiquier[xmat2][ymat2] = mat_echiquier[xmat][ymat];
									couleur[xmat2][ymat2] = Ntemc;
									echiquier[xmat][ymat] = ' ';
									couleur[xmat][ymat] = ' ';
									verifechec(temc);
									if (testverifechec == 0 )
									{
										testverifmat = 0;
										mat_progress[xmat][ymat]=  '/';
									}
									copitab(couleur,mat_couleur);
									copitab(echiquier,mat_echiquier);
		
								}
							}
						}
					}
				}
			}
			if (testverifmat == 1)
			{
				sprintf(buf,"Le roi %s est échec et mat !!", (temc == 'B') ? "noir":"blanc");
				MessageBox(hwnd,buf,"Thym's Chessgame",MB_OK | MB_ICONINFORMATION);
			}
			else
			{
				sprintf(buf,"Le roi %s est en échec !!", (temc == 'B') ? "noir":"blanc");
				MessageBox(hwnd,buf,"Thym's Chessgame",MB_OK | MB_ICONINFORMATION);
				
			}
			copitab(progress,mat_progress) ;
	    
		}
	}
    
    void promotion(HWND hwnd)
	{
		if (temp == 'p' && temc == 'N' && yfinal == 7 || temp == 'p' && temc == 'B' && yfinal == 0) 
		{
			//sprintf(buf,"TEST");
			//MessageBox(hwnd,buf,"Info",MB_ICONWARNING/*,MB_OK*/);
			//if ( Ppromotion != 'D' && Ppromotion != 'F' && Ppromotion != 'C' && Ppromotion != 'T') Ppromotion = 'D';
			temp = Ppromotion;
		}
	}
    
    void verifroques(){
		int testverifroques = 0;
		initMAT();
		if (temc2 == 'N') Ntemc2 = 'B';
		else Ntemc2 = 'N';
		if (temc2 == 'N' && temp2 == 'R')
		{
	    	if (RNdeplac==0&&TN0deplac==0&&echiquier[1][0]==' '&&echiquier[2][0]==' '&&echiquier[3][0]==' ')
			{
				for(y = 0; y < 8; y++)
				{
					for(x = 0; x < 8; x++)
					{
						if (couleur[x][y] == Ntemc2)
						{
							possdedeplac(x,y);
							if (progress[1][0]=='*'||progress[2][0]=='*'||progress[3][0]=='*'||progress[4][0]=='*') testverifroques = 1;
						}
					}
				}
				if (testverifroques == 0) mat_progress[2][0]='R';
				testverifroques = 0;
			}
			if (RNdeplac==0&&TN7deplac==0&&echiquier[5][0]==' '&&echiquier[6][0]==' ')
			{
				for(y = 0; y < 8; y++)
				{
					for(x = 0; x < 8; x++)
					{
						if (couleur[x][y] == Ntemc2)
						{
							possdedeplac(x,y);
							if (progress[5][0]=='*'||progress[6][0]=='*'||progress[4][0]=='*') testverifroques = 1;
						}
					}
				}
				if (testverifroques == 0) mat_progress[6][0]='R';
				testverifroques = 0;
			}
	    
		}
	    
		if (temc2 == 'B' && temp2 == 'R')
		{
			if (RBdeplac==0&&TB0deplac==0&&echiquier[1][7]==' '&&echiquier[2][7]==' '&&echiquier[3][7]==' ')
			{
				for(y = 0; y < 8; y++)
				{
					for(x = 0; x < 8; x++)
					{
						if (couleur[x][y] == Ntemc2)
						{
							possdedeplac(x,y);
							if (progress[1][7]=='*'||progress[2][7]=='*'||progress[3][7]=='*'||progress[4][7]=='*') testverifroques = 1;
						}
					}
				}
				if (testverifroques == 0) mat_progress[2][7]='R';
				testverifroques = 0;
			}
			if (RBdeplac==0&&TB7deplac==0&&echiquier[5][7]==' '&&echiquier[6][7]==' ') 
			{
				for(y = 0; y < 8; y++)
				{
					for(x = 0; x < 8; x++)
					{
						if (couleur[x][y] == Ntemc2)
						{
							possdedeplac(x,y);
							if (progress[5][7]=='*'||progress[6][7]=='*'||progress[4][7]=='*') testverifroques = 1;
						}
					}
				}
				if (testverifroques == 0) mat_progress[6][7]='R';
				testverifroques = 0;
			}
		}
		copitab(progress,mat_progress);
	}
        
    void roques(){
		if (temp == 'R' && temc =='B') RBdeplac = 1;
		if (temp == 'R' && temc =='N') RNdeplac = 1;
		if (temp == 'T' && temc =='B' && xinit == 0) TB0deplac = 1;
		if (temp == 'T' && temc =='N' && xinit == 0) TN0deplac = 1;
		if (temp == 'T' && temc =='B' && xinit == 7) TB7deplac = 1;
		if (temp == 'T' && temc =='N' && xinit == 7) TN7deplac = 1;
		if (progress[xfinal][yfinal] == 'R')
		{
			if (xfinal == 2 && yfinal == 0) echiquier[xfinal+1][yfinal]='T',echiquier[xfinal-2][yfinal]=' ',couleur[xfinal+1][yfinal]='N',couleur[xfinal-2][yfinal]=' ';
			if (xfinal == 6 && yfinal == 0) echiquier[xfinal-1][yfinal]='T',echiquier[xfinal+1][yfinal]=' ',couleur[xfinal-1][yfinal]='N',couleur[xfinal+1][yfinal]=' ';
			if (xfinal == 2 && yfinal == 7) echiquier[xfinal+1][yfinal]='T',echiquier[xfinal-2][yfinal]=' ',couleur[xfinal+1][yfinal]='B',couleur[xfinal-2][yfinal]=' ';
			if (xfinal == 6 && yfinal == 7) echiquier[xfinal-1][yfinal]='T',echiquier[xfinal+1][yfinal]=' ',couleur[xfinal-1][yfinal]='B',couleur[xfinal+1][yfinal]=' ';
		}
		////prise en passant
		if (yinit == 1 && yfinal == 3 && temp == 'p') echiquier[xinit][2] = 'P', couleur[xinit][2] = 'N';
		if (yinit == 6 && yfinal == 4 && temp == 'p') echiquier[xinit][5] = 'P', couleur[xinit][5] = 'B';
	    
    }
    
    void clouage(){
		int temtestverifechec = testverifechec;
		testverifechec = 0;
		initMAT();
		initNtemc();
		for(y = 0; y < 8; y++)
		{
			for(x = 0; x < 8; x++)
			{
				if (progress[x][y] == '*') 
				{
					echiquier[x][y] = temp;
					couleur[x][y] = temc;
					echiquier[xinit][yinit] = ' ';
					couleur[xinit][yinit] = ' ';
					verifechec(Ntemc);
					if (testverifechec == 1) progress[x][y] = ' ' ;
					copitab(couleur,mat_couleur);
					copitab(echiquier,mat_echiquier);
					testverifechec = temtestverifechec;
				}
			}
		}
	}
    //// Fonctions de l'interface Thym's Win32API
    
    
    int Mxselect2, Myselect2;
    
	 /****modifications sur les couleurs apportées le 26 avril 2007 par mélanie gagné****/
	
     //modifie les couleurs de l'interface
    void coloration()
	{	
		POINT pt;
		GetCursorPos(&pt);  // On récupère la position écran
		HWND hwnd;
		
		//bleu
		if ((pt.x > 500 && pt.x < 660) && (pt.y > 0 && pt.y  < 290))
		{
			
			Casesviolettes = CreateSolidBrush(RGB(39,43,100)); // brosse
			Casesgrises = CreateSolidBrush(RGB(7, 45, 182)); // brosse
			colorer = 1;
			ScreenToClient(hwnd,&pt);
		}
		//vert
		if ((pt.x > 500 && pt.x < 660) && (pt.y  > 290 && pt.y  < 490))
		{
			
			Casesviolettes = CreateSolidBrush(RGB(234,43,10)); // brosse
			Casesgrises = CreateSolidBrush(RGB(107, 145, 12)); // brosse
			colorer = 2;
			ScreenToClient(hwnd,&pt);
		}
		//rouge
		if ((pt.x > 500&& pt.x < 660) && (pt.y  > 490 && pt.y  < 690))
		{
		
			Casesviolettes = CreateSolidBrush(RGB(200,50,100)); // brosse
			Casesgrises = CreateSolidBrush(RGB(225, 136, 182)); // brosse
			colorer = 3;
			ScreenToClient(hwnd,&pt);
		}

	}
	// Dessine la page    // Affiche l'échiquier + pièces
    void AfficheEchiquier(HWND hwnd) { 
    hdc = BeginPaint (hwnd, &ps);
	// début du dessin
    //*******************Couleur de l'échiquier*********************
    
//*******23 Avril 2007: Création des textes*********
	// Par Mélanie Gagné
  //   BitBlt(hdc, 512,0,x+138,512, hdcMemPion, 0, 0, SRCAND);
	//changement des couleurs lors du click sur le bouton
	
		POINT pt;
		coloration();
		
		if (colorer ==1)
		{//bleu
			Casesviolettes = CreateSolidBrush(RGB(40,10,100)); // brosse
			Casesgrises = CreateSolidBrush(RGB(7, 45, 182)); // brosse
			colorer = 1;//dira que la couleur est bleu, donc de la laissé bleu
			ScreenToClient(hwnd,&pt);//actualise la fenetre pour mettre le tout en bleu.
		}
		else
			if (colorer ==2)
			{//Vert
				Casesviolettes = CreateSolidBrush(RGB(50,93,51)); // brosse
				Casesgrises = CreateSolidBrush(RGB(97, 179, 32)); // brosse
				colorer = 2;
				ScreenToClient(hwnd,&pt);
			}
			else
				if (colorer ==3)
				{//Rouge
					Casesviolettes = CreateSolidBrush(RGB(200,50,100)); // brosse
					Casesgrises = CreateSolidBrush(RGB(225, 136, 182)); // brosse
					colorer = 3;
					ScreenToClient(hwnd,&pt);
				}
	//ScreenToClient(hwnd,&pt);
	//********************************************************************************//
	//26 avril 2007, création des boutons pour changer les couleurs
	
	//BitBlt(hdc, 540, 80,580, 100, hdcVert, 0, 0,/*MERGEPAINT);//*/SRCAND);
			
    //******************** Selectionne les nouveaux outils et dessine.****************
    SelectObject(hdc, Casesgrises);
    int x=0,y=0;
    for (x=0; x<=448; x+=128)
	{	Rectangle(hdc, x,0,64+x,64);
		Rectangle(hdc, x,128,64+x,192);
		Rectangle(hdc, x,256,64+x,320);
		Rectangle(hdc, x,384,64+x,448);
    }
    for (x=64; x<=512; x+=128)
	{	
		Rectangle(hdc, x,64,64+x,128);
		Rectangle(hdc, x,192,64+x,256);
		Rectangle(hdc, x,320,64+x,384);
		Rectangle(hdc, x,448,64+x,512);
    }
    // Selectionne les nouveaux outils et dessine les rectangles contenant les pièces
    SelectObject(hdc, Casesviolettes);
    for (x=64; x<=512; x+=128)
	{
		Rectangle(hdc, x,0,64+x,64);
		Rectangle(hdc, x,128,64+x,192);
		Rectangle(hdc, x,256,64+x,320);
		Rectangle(hdc, x,384,64+x,448);
	
    }
    for (x=0; x<=448; x+=128)
	{
		Rectangle(hdc, x,64,64+x,128);
		Rectangle(hdc, x,192,64+x,256);
		Rectangle(hdc, x,320,64+x,384);
		Rectangle(hdc, x,448,64+x,512);
    }
	//19 avril 2007: Menu pour les modifications apportées par mélanie gagné
	SelectObject(hdc, Casesgrises);
	Rectangle(hdc, 512,0,640,512);
//	BitBlt(hdc, 538, 200,558, 220, hdcVert, 0, 0,/*MERGEPAINT);//*/SRCAND);
	
	


   // *************************** petit carré rouge de sélection**********************
    
    HPEN SelecCase = CreatePen(PS_SOLID, 3, RGB(255, 0, 0)); // pinceau
    SelectObject(hdc, GetStockObject(NULL_BRUSH));
    SelectObject(hdc, SelecCase);
    Rectangle(hdc, xselec2*64,yselec2*64,(xselec2+1)*64,(yselec2+1)*64);
	
    //***********************Création des pièces selon la couleur****************
    
    for(y = 0; y < 8; y++)
    {
		for(x = 0; x < 8; x++)
		{
			if (couleur[x][y] == 'B')
			{
				if (echiquier[x][y] == 'v') BitBlt(hdc, x*64, y*64,64, 64, hdcVert,			0, 0, MERGEPAINT);
				if (echiquier[x][y] == 'T') BitBlt(hdc, x*64, y*64,64, 64, hdcMemTour,		0, 0, MERGEPAINT); // roi blanc fond tranparent
				if (echiquier[x][y] == 'C') BitBlt(hdc, x*64, y*64,64, 64, hdcMemCavalier,	0, 0, MERGEPAINT);
				if (echiquier[x][y] == 'F') BitBlt(hdc, x*64, y*64,64, 64, hdcMemFou,		0, 0, MERGEPAINT);
				if (echiquier[x][y] == 'D') BitBlt(hdc, x*64, y*64,64, 64, hdcMemDame,		0, 0, MERGEPAINT);
				if (echiquier[x][y] == 'R') BitBlt(hdc, x*64, y*64,64, 64, hdcMemRoi,		0, 0, MERGEPAINT);
				if (echiquier[x][y] == 'p') BitBlt(hdc, x*64, y*64,64, 64, hdcMemPion,		0, 0, MERGEPAINT);
			}
			if (couleur[x][y] == 'N')
			{
				if (echiquier[x][y] == 'T') BitBlt(hdc, x*64, y*64,64, 64, hdcMemTour,		0, 0, SRCAND);// roi noir fond tranparent
				if (echiquier[x][y] == 'C') BitBlt(hdc, x*64, y*64,64, 64, hdcMemCavalier,	0, 0, SRCAND);
				if (echiquier[x][y] == 'F') BitBlt(hdc, x*64, y*64,64, 64, hdcMemFou,		0, 0, SRCAND);
				if (echiquier[x][y] == 'D') BitBlt(hdc, x*64, y*64,64, 64, hdcMemDame,		0, 0, SRCAND);
				if (echiquier[x][y] == 'R') BitBlt(hdc, x*64, y*64,64, 64, hdcMemRoi,		0, 0, SRCAND);
				if (echiquier[x][y] == 'p') BitBlt(hdc, x*64, y*64,64, 64, hdcMemPion,		0, 0, SRCAND);
				}
	
		}
	}
	// BitBlt(hdc, 540, 10,580, 30, bttnPngVert, 0, 0,SRCAND);
	//24 avril 2007 Création du texte sur le côté.
	SetTextColor (hdc,RGB(72,129,200));
    TextOut (hdc,514,3," Quelles couleurs",17);
	TextOut (hdc,514,19," Désirez-vous ?",15);
	//TextOut (hdc,514,67," Vert ?",6);

    
    //SetBkMode(hdc, TRANSPARENT);
    //SetTextColor(hdc, RGB(150, 20, 100)); // ecrit en gris
    //TextOut (hdc, 10,515,"Bienvenue dans Thym's Winchessgame",34);
    //TextOut (hdc, 10,532,"Basé sur le core MAChessengine v0.65cc2 & MAChessAi v0.0bêta",60);
    //TextOut (hdc, 10,549,"Conception et création : M.A. Cottard",37);
    //TextOut (hdc, 10,566,"Testeur et conception des pièces : S. Héron",43);
    EndPaint (hwnd, &ps); // fin du dessin
    }
    
    
    // Sélection des cases avec la souris
    void SelectionCase (HWND hwnd) {     
		POINT pt;
		GetCursorPos(&pt);  // On récupère la position écran
		ScreenToClient(hwnd,&pt);
		int x,y;
		x=0,y=0;
		if (pt.x < 512 && pt.x > 0 && pt.y < 512 && pt.y > 0)
		{	
			while (x < pt.x) 
				{
					x = x + 64;
				}
			xselec = (x / 64) - 1;
			while (y < pt.y) 
				{
					y = y + 64;}
					yselec = (y / 64) - 1;
				}
		//testselectcase = 1;
		}
	    
    // ****************************************Pièces********************************
	//02-05-07:Ajout des boutons de sélection par Melanie Gagné
	// importation des pièces
    void ImportPieces(HINSTANCE hInstance,HWND hwnd)
	{    
    
		hBmpRoi         = (HBITMAP) LoadImage(NULL,"Roi.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemRoi       = CreateCompatibleDC(hdc);
		hBmpDame        = (HBITMAP) LoadImage(NULL,"Dame.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemDame      = CreateCompatibleDC(hdc);
		hBmpFou         = (HBITMAP) LoadImage(NULL,"Fou.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemFou       = CreateCompatibleDC(hdc);
		hBmpCavalier    = (HBITMAP) LoadImage(NULL,"Cavalier.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemCavalier  = CreateCompatibleDC(hdc);
		hBmpTour        = (HBITMAP) LoadImage(NULL,"Tour.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemTour      = CreateCompatibleDC(hdc);
		hBmpPion        = (HBITMAP) LoadImage(NULL,"Pion.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcMemPion      = CreateCompatibleDC(hdc);
	//	bttnPgnBleu		= (HBITMAP) LoadImage(NULL,"Bleu.png",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
	//		hdcBleu			= CreateCompatibleDC(hdc);
		bttnPngVert		= (HBITMAP) LoadImage(NULL,"Vert.bmp",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
			hdcVert			= CreateCompatibleDC(hdc);
	//	bttnPngRouge	= (HBITMAP) LoadImage(NULL,"Rouge.png",IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE);
	//		hdcRouge		= CreateCompatibleDC(hdc);

		//hdc = GetDC(hwnd);
		SelectObject(hdcMemRoi,   hBmpRoi);
		SelectObject(hdcMemDame,  hBmpDame);
		SelectObject(hdcMemFou, hBmpFou);
		SelectObject(hdcMemCavalier, hBmpCavalier);
		SelectObject(hdcMemTour,   hBmpTour);
		SelectObject(hdcMemPion,   hBmpPion);
		//*****************************************//
		SelectObject(hdcVert,	bttnPngVert);
		//*****************************************//
		// ReleaseDC(hwnd,hdc);
    }
    
    
    //// Fonctions AI   (En test de Developpement)
    void jeuAi(HWND hwnd) {
		int eval = 0;
		//initNtemc();
		mat2_progress[8][8]=progress[8][8];
		if (mat2_couleur[xai][yai] == 'N') 
		{
			for(yai2 = 0; yai2 < 8; yai2++)
			{
				for(xai2 = 0; xai2 < 8; xai2++)
				{
					if (progress[xai2][yai2] == '*' || progress[xai2][yai2] == 'R') 
					{
						//eval = eval + rand()%5;
						if (mat2_couleur[xai2][yai2] == 'B' && mat2_echiquier[xai2][yai2] == 'D')
							eval = eval + 45 ;
						if (mat2_couleur[xai2][yai2] == 'B' && mat2_echiquier[xai2][yai2] == 'T') 
							eval = eval + 35 ;
						if (mat2_couleur[xai2][yai2] == 'B' && mat2_echiquier[xai2][yai2] == 'F') 
							eval = eval + 23 ;
						if (mat2_couleur[xai2][yai2] == 'B' && mat2_echiquier[xai2][yai2] == 'C') 
							eval = eval + 23 ;
						if (mat2_couleur[xai2][yai2] == 'B' && mat2_echiquier[xai2][yai2] == 'p') 
							eval = eval + 10 ;
						
						couleur[xai2][yai2] = 'B';
						echiquier[xai2][yai2] = mat2_echiquier[xai][yai];
						couleur[xai][yai] = ' ';
						echiquier[xai][yai] = ' ';
	   
						for(yai3 = 0; yai3 < 8; yai3++)
						{
							for(xai3 = 0; xai3 < 8; xai3++)
							{
								if (couleur[xai3][yai3] == 'N')
								{
									possdedeplac(xai3,yai3);
									if (progress[xai2][yai2] == '*') eval = eval + 5;   // protection des pièces
								}
							}
						}
						couleur[xai2][yai2] = 'N';
						///
						for(yai3 = 0; yai3 < 8; yai3++)
						{
							for(xai3 = 0; xai3 < 8; xai3++)
							{
								if (couleur[xai3][yai3] == 'N')
								{
									couleur[xai3][yai3] = 'B';
									for(yai4 = 0; yai4 < 8; yai4++)
									{
										for(xai4 = 0; xai4 < 8; xai4++)
										{
											if (couleur[xai4][yai4] == 'N') 
											{
												possdedeplac(xai4,yai4);
												if (progress[xai3][yai3] == '*') eval = eval + 2 ;
											}
										}
									}
										couleur[xai3][yai3] = 'N';
										possdedeplac(xai3,yai3);
										for(yai4 = 0; yai4 < 8; yai4++)
										{
											for(xai4 = 0; xai4 < 8; xai4++)
											{
												if (progress[xai4][yai4] == '*') 
												{
													if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'R') 
														eval = eval + 30;
													if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'D') 
														eval = eval + 20;
													if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'T') 
														eval = eval + 12;
													if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'F')
														eval = eval + 8;
													if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'C')
														eval = eval + 8;
									//if (couleur[xai4][yai4] == 'B' && echiquier[xai4][yai4] == 'p') eval = eval + 1;
												}
											}
										}
								}
							}
						}
						//couleur[xai2][yai2] = ' ';
						//echiquier[xai2][yai2] = ' ';
						verifechec('B');
						if (testverifechec == 1) testverifechec = 0, eval = eval - 10000;
						for(yai3 = 0; yai3 < 8; yai3++)
						{	
							for(xai3 = 0; xai3 < 8; xai3++)
							{
								if (couleur[xai3][yai3] == 'B')
								{
									possdedeplac(xai3,yai3);
									for(yai4 = 0; yai4 < 8; yai4++)
									{
										for(xai4 = 0; xai4 < 8; xai4++)
										{
											if (progress[xai4][yai4] == '*') 
											{
												if (echiquier[xai4][yai4] == 'R') eval = eval - 10000;
												if (echiquier[xai4][yai4] == 'D') eval = eval - 45 ;
												if (echiquier[xai4][yai4] == 'T') eval = eval - 35 ;
												if (echiquier[xai4][yai4] == 'C') eval = eval - 25 ;
												if (echiquier[xai4][yai4] == 'F') eval = eval - 25 ;
												if (echiquier[xai4][yai4] == 'p') eval = eval - 8;
											}
										}
									}
								}
							}
						}
						//if (yai2 == 3 || yai2 ==4 )  eval = eval + 4 ;
						if (xai2 == 3 || xai2 == 4 )  eval = eval + 3 ;
						if (yai2 > yai) eval = eval + 5;
						if (mat2_echiquier[xai][yai] =='R') eval = eval - 15;
						//InvalidateRect (hwnd, NULL, FALSE);
						//sprintf(buf,"L'évaluation est : %d\n",eval);
						//MessageBox(hwnd,buf,"Info",MB_ICONEXCLAMATION);
						if (eval > eval1) 
						{
							temc = 'N';
							temp = mat2_echiquier[xai][yai];
							eval1 = eval;
							xinit  = xai;
							yinit  = yai;
							xfinal = xai2;
							yfinal = yai2;
							eval = 0;
						}
	    
						copitab(couleur,mat2_couleur);
						copitab(echiquier,mat2_echiquier);
						copitab(progress,mat2_progress);
						eval = 0;
					}
				}
			}
		}
}
    void AI (HWND hwnd){
		initMAT2();
		for(yai = 0; yai < 8; yai++)
		{ 
			for(xai = 0; xai < 8; xai++)
			{ 
				if (mat2_couleur[xai][yai] != ' ')
				{
					//temc = couleur[xai][yai];
					//temp = echiquier[xai][yai];
					possdedeplac(xai,yai);
					verifroques();
					clouage();
					jeuAi(hwnd);
				}
    		}
		}
		copitab(couleur,mat2_couleur);
		copitab(echiquier,mat2_echiquier);
		eval2 = eval1;
		eval1 = -50000;
    }
    
    
    
    //////***********************Action de Jeu**************************** //////
    char mat3_progress[8][8];
    void JoueurJoue(HWND hwnd){
		switch (c) 
		{
		case  0 :   
			SelectionCase (hwnd);
			xinit = xselec;
			yinit = yselec;
			copitab(mat3_progress,progress);
			Rejouer :
			temc = couleur[xinit][yinit];
			temp = echiquier[xinit][yinit];
	    
			if (testverifechec == 1) if (mat3_progress[xinit][yinit] != '/')
			{
				// sprintf(buf," !!! Echec et mat !!! ");
				//MessageBox(hwnd,buf,"Info",MB_ICONWARNING);
				break;
			}
			verifcouleur();
			if (testverifcouleur == 1)  break;
			possdedeplac(xinit,yinit);
			verifroques();
			clouage();
			pouvoirdeplac();
			if (testpouvoirdeplac == 1) break;
			xselec2 = xselec;
			yselec2 = yselec;
			InvalidateRect (hwnd, NULL, FALSE);
			c = 2;
		break;
	    
		case 2 :
			SelectionCase (hwnd);
			xfinal = xselec;
			yfinal = yselec;
			verifdeplac();
			///////////// Possibilité de rejouer
			if (testverifdeplac == 2)
			{
				xinit = xfinal;
				yinit = yfinal;
				goto Rejouer;
			}
		/////////////////////
			if (testverifdeplac == 1) break;
			if (testverifechec == 1)
			{
				echiquier[xinit][yinit] = ' ', couleur[xinit][yinit] = ' ';
				echiquier[xfinal][yfinal] = temp, couleur [xfinal][yfinal] = temc;
				initNtemc();
				verifechec(Ntemc);
				if (testverifechec == 1)
				{
					echiquier[xinit][yinit] = temp, couleur[xinit][yinit] = temc;
					echiquier[xfinal][yfinal] = ' ', couleur [xfinal][yfinal] = ' '; 
					break;
				}
			}
			xselec2 = xselec;
			yselec2 = yselec;
			promotion(hwnd);
			if (echiquier[xfinal][yfinal] == 'P' && couleur[xfinal][yfinal] == 'B') echiquier[xfinal][4] = ' ' , couleur[xfinal][4] = ' ' ;
			if (echiquier[xfinal][yfinal] == 'P' && couleur[xfinal][yfinal] == 'N') echiquier[xfinal][3] = ' ' , couleur[xfinal][3] = ' ' ;
			echiquier[xinit][yinit] = ' ', couleur[xinit][yinit] = ' ';
			echiquier[xfinal][yfinal] = temp, couleur [xfinal][yfinal] = temc;
			roques();
			possdedeplac(xfinal,yfinal);    
			compteurdemicoup = compteurdemicoup + 1;
			verifmat(hwnd);
			InvalidateRect (hwnd, NULL, FALSE);
			c = 0;
		break;
    
		}
	}
    
    void AiJoue(HWND hwnd)
	{
		switch (c) 
		{
			case  0 :
				AI(hwnd);
				xselec2 = xinit;
				yselec2 = yinit;
				InvalidateRect (hwnd, NULL, FALSE);
				c = 2;
			break;
	    
			case 2 :
				SelectionCase (hwnd);
				//verifdeplac();
				//if (testverifdeplac == 1) break;
				xselec2 = xfinal;
				yselec2 = yfinal;
				promotion(hwnd);
				echiquier[xfinal][yfinal] = echiquier[xinit][yinit], couleur [xfinal][yfinal] = couleur[xinit][yinit];
				echiquier[xinit][yinit] = ' ', couleur[xinit][yinit] = ' ';
				roques();
				if (temp == 'R' && temc =='B') RBdeplac = 1;
				if (temp == 'R' && temc =='N') RNdeplac = 1;
				if (temp == 'T' && temc =='B' && xinit == 0) TB0deplac = 1;
				if (temp == 'T' && temc =='N' && xinit == 0) TN0deplac = 1;
				if (temp == 'T' && temc =='B' && xinit == 7) TB7deplac = 1;
				if (temp == 'T' && temc =='N' && xinit == 7) TN7deplac = 1;
				possdedeplac(xfinal,yfinal);
				c = 0;
				compteurdemicoup = compteurdemicoup + 1;
				verifmat(hwnd);
				InvalidateRect (hwnd, NULL, FALSE);
				//sprintf(buf," !!! Echec et mat !!! ");
				//MessageBox(hwnd,buf,"Info",MB_ICONWARNING);
				//sprintf(buf,"L'évaluation est : %d\n",eval2);
				//MessageBox(hwnd,buf,"Info",MB_ICONEXCLAMATION);
			break;
	   }
	}
    
    
    
    //// Interface graphique Thym's Win32API
    /// Déclarations
    LRESULT CALLBACK WindowProcedure(HWND, UINT, WPARAM, LPARAM);
    char szClassName[ ] = "WindowsApp"; // nom de la classe en var globale
    
    /// Début
    int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
    LPSTR lpszArgument, int nFunsterStil) {
		// Déclarations
		
		
			
		HWND hwnd, hwnd2; MSG messages; WNDCLASSEX wincl;
		// Structure de la fenêtre
		wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName;
		wincl.lpfnWndProc = WindowProcedure; // Fonction appelée par Windows
		wincl.style = CS_HREDRAW|CS_VREDRAW; // Redessine à chaque fois
		
		wincl.cbSize = sizeof(WNDCLASSEX);
		// Icônes, pointeur, etc
		 wincl.hIcon = LoadIcon(NULL,IDI_APPLICATION);    //NULL, IDI_APPLICATION
		 wincl.hIconSm = LoadIcon(NULL, "TWCG.ico");
		wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
		wincl.lpszMenuName = NULL;
		wincl.cbClsExtra = 0;
		wincl.cbWndExtra = 0;
		wincl.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH); // Fond gris clair
		// Enregistre la classe sinon quitte le programme
		if(!RegisterClassEx(&wincl)) return 0;
    
		// Création de la fenêtre**************
		hwnd = CreateWindowEx(0, szClassName,
		"Thym's Winchessgame", // Titre
		WS_OVERLAPPEDWINDOW, // Fenêtre par défaut
			GetSystemMetrics(SM_CXSCREEN)/4, // left 
		//**** GetSystemMetrics donne la dimension de l'écran de l'utilisateur
		//le jeu sera donc de la proportion déterminée pour un affichage pas trop grand ni 
		//trop petit.
		GetSystemMetrics(SM_CYSCREEN)/4, // top
		660,
		//19-04-2007:Nouvelle grandeur pour l'ajout des fonctions (Mélanie Gagné)
		//520,//GetSystemMetrics(SM_CXSCREEN)/2, // width est l'ancienne grandeur de fenêtre
		546,//GetSystemMetrics(SM_CYSCREEN)/2, // height
		HWND_DESKTOP, NULL, hThisInstance, NULL );//****************
    
	    
		// Montre la fenêtre
		ShowWindow(hwnd, nFunsterStil);
		UpdateWindow(hwnd);
    

    
		// Boucle jusqu'à ce que GetMessage() retourne 0
		while(GetMessage(&messages, NULL, 0, 0))
		{
			DispatchMessage(&messages);
		}
		
		return messages.wParam;
	
    }

    ///Messages Win d'instrucion
    
    // Fonction appelée par la fonction Windows DispatchMessage()
    LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
	{
		switch (message) { // Intercepte les messages
			case WM_CREATE:
				ImportPieces(hInstance,hwnd);
			return 0;
			case WM_PAINT: // La fenêtre doit être redessinée
				AfficheEchiquier(hwnd);
			return 0;
			case WM_LBUTTONDOWN:  // Le bouton gauche est pressé
				coloration();
				couleurajouer = compteurdemicoup % 2;
		    
				 /*if  (couleurajouer == 0) {
				  AiJoue(hwnd);
				  else {   */
				JoueurJoue(hwnd);
				DialogBox (hInstance, TEXT ("AboutBox"), hwnd, NULL);
				//}
    
			return 0 ;
    
			case WM_DESTROY: // Destruction de la fenêtre
				PostQuitMessage(0); // Envoie WM_QUIT à Windows
			break;
			default: // Messages non gérés
			return DefWindowProc(hwnd, message, wParam, lParam);
		}
    return 0;
    }

Conclusion :

Merci a google de m'avoir aider a comprendre certains code ...
Merci a ma mère et a mon petit copain pour son soutien

et bonne chance pour les prochains qui retoucherons le code.

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.