Advertisement
Guest User

Untitled

a guest
Nov 25th, 2010
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 218.21 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <SDL.h>
  4. #include <SDL_image.h>
  5. #include <SDL\SDL_ttf.h>
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9. SDL_Surface *ecran = NULL, *selectMenu = NULL, *textureDeFond = NULL; // Le pointeur qui va stocker la surface de l'écran
  10. SDL_Surface *menu = NULL, *menu1 = NULL, *menu2 = NULL, *menu3 = NULL, *menu4 = NULL, *menu5 = NULL, *menu6 = NULL, *menu7 = NULL;
  11. SDL_Surface *ssMenu1 = NULL, *ssMenu2 = NULL,*ssMenu3 = NULL, *ssMenu4 = NULL, *ssMenu5 = NULL, *ssMenu6 = NULL;
  12. SDL_Surface *texteSelect;
  13. SDL_Surface *pieceJeuOff1N, *pieceJeuDef1N, *pieceJeuOff2N, *pieceJeuDef2N;
  14. SDL_Surface *pieceOff1N, *pieceDef1N, *pieceOff2N, *pieceDef2N;
  15. SDL_Surface *pieceOff1B, *pieceDef1B, *pieceOff2B, *pieceDef2B;
  16. SDL_Surface *pieceOff1R, *pieceDef1R, *pieceOff2R, *pieceDef2R;
  17. SDL_Surface *pieceOff1V, *pieceDef1V, *pieceOff2V, *pieceDef2V;
  18. SDL_Surface *pieceOff1Bl, *pieceDef1Bl, *pieceOff2Bl, *pieceDef2Bl;
  19. SDL_Surface *pieceOff1J, *pieceDef1J, *pieceOff2J, *pieceDef2J;
  20. SDL_Surface *pieceOff1C, *pieceDef1C, *pieceOff2C, *pieceDef2C;
  21. SDL_Surface *pieceOff1M, *pieceDef1M, *pieceOff2M, *pieceDef2M;
  22. SDL_Surface *touchePre1, *toucheSui1, *touchePre2, *toucheSui2, *touchePre3, *toucheSui3, *touchePre4, *toucheSui4, *touchePre5, *toucheSui5, *touchePre6, *toucheSui6, *touchePre7, *toucheSui7;
  23. SDL_Surface *textureDamFond = NULL, *textureFond = NULL, *textureEtoile = NULL, *textureForet = NULL, *texturePlage = NULL, *textureNuit = NULL;
  24. SDL_Surface *textureEtoile2 = NULL, *textureForet2 = NULL, *textureNuit2 = NULL, *texturePlage2 = NULL;
  25. SDL_Surface *damierInc400400NB = NULL, *damierInc800800NB = NULL, *textureDamier = NULL, *reglageVol = NULL, *txtRegDuVol = NULL;
  26. SDL_Surface *txtTexture = NULL, *selectBoutonVol = NULL, *selectVolume = NULL;
  27. SDL_Surface *carreRouge1, *carreVert1, *carreBleu1, *carreRouge2, *carreVert2, *carreBleu2, *rouge1, *vert1, *bleu1, *rouge0, *vert0, *bleu0;
  28. SDL_Surface *carreBlanc = NULL, *textJ1Commence;
  29. SDL_Surface *regleJeu1 = NULL, *regleJeu2 = NULL, *regleJeu3 = NULL, *regleJeu4 = NULL, *regleJeu5 = NULL, *regleJeu6 = NULL, *regleJeu7 = NULL;
  30. SDL_Surface *txtDeplaNA;
  31. SDL_Surface *CubikRed, *CubikBlue;
  32.  
  33. SDL_Rect positionFond, positionDamFond, positionNuit, positionPlage, positionForet, positionEtoile;
  34. SDL_Rect positionEtoile2, positionNuit2, positionPlage2, positionForet2;
  35. SDL_Rect posSelectMenu, positionMenu,positionMenu1,positionMenu2,positionMenu3,positionMenu4,positionMenu5,positionMenu6,positionMenu7;
  36. SDL_Rect positionSsMenu1, positionSsMenu2, positionSsMenu3, positionSsMenu4, positionSsMenu5, positionSsMenu6;
  37. SDL_Rect posTexteSelect, posDamInc800800NB;
  38. SDL_Rect positionPre1, positionSui1, positionPre2, positionSui2,positionSui3, positionPre3, positionPre4, positionSui4, positionPre5, positionSui5, positionSui6, positionPre6, positionSui7, positionPre7;
  39. SDL_Rect posPieceOff1N, posPieceDef1N, posPieceOff2N, posPieceDef2N;
  40. SDL_Rect posPieceJOff1N1, posPieceJDef1N1, posPieceJOff1N2, posPieceJDef1N2, posPieceJOff1N3, posPieceJDef1N3, posPieceJOff1N4, posPieceJDef1N4, posPieceJOff1N5, posPieceJDef1N5, posPieceJOff1N6, posPieceJDef1N6;
  41. SDL_Rect posPieceJOff2N1, posPieceJDef2N1, posPieceJOff2N2, posPieceJDef2N2, posPieceJOff2N3, posPieceJDef2N3, posPieceJOff2N4, posPieceJDef2N4, posPieceJOff2N5, posPieceJDef2N5, posPieceJOff2N6, posPieceJDef2N6;
  42. SDL_Rect posPieceOff1B, posPieceDef1B, posPieceOff2B, posPieceDef2B;
  43. SDL_Rect posPieceOff1R, posPieceDef1R, posPieceOff2R, posPieceDef2R;
  44. SDL_Rect posPieceOff1V, posPieceDef1V, posPieceOff2V, posPieceDef2V;
  45. SDL_Rect posPieceOff1Bl, posPieceDef1Bl, posPieceOff2Bl, posPieceDef2Bl;
  46. SDL_Rect posPieceOff1J, posPieceDef1J, posPieceOff2J, posPieceDef2J;
  47. SDL_Rect posPieceOff1C, posPieceDef1C, posPieceOff2C, posPieceDef2C;
  48. SDL_Rect posPieceOff1M, posPieceDef1M, posPieceOff2M, posPieceDef2M;
  49. SDL_Rect positionTextureD, positionTextureF, positionReglageV;
  50. SDL_Rect posDamInc400400VB, posTxtTexture, posSelectVol, posBoutonVol, posTxtReglageV;
  51. SDL_Rect posCarreRouge1, posCarreVert1, posCarreBleu1, posCarreRouge2, posCarreVert2, posCarreBleu2;
  52. SDL_Rect posRouge1A, posVert1A, posBleu1A, posRouge0A, posVert0A, posBleu0A, posRouge1B, posVert1B, posBleu1B, posRouge0B, posVert0B, posBleu0B;
  53. SDL_Rect posTxtJ1C;
  54. SDL_Rect posRegleJeu1, posRegleJeu2, posRegleJeu3, posRegleJeu4, posRegleJeu5, posRegleJeu6, posRegleJeu7;
  55. SDL_Rect posTxtDeplaNA;
  56. SDL_Rect posCubikRed,posCubikBlue;
  57.  
  58.  
  59. TTF_Font *police = NULL;
  60. SDL_Color couleurNoire = {0, 0, 0};
  61. SDL_Event event;
  62. int continuer = 1, continuer1 = 1, continuer2 = 1, compteurDebut = 1;
  63. int compteurFond = 0, compteurRegle = 0;
  64. int comptR1 = 0, comptV1 = 0, comptB1 = 0, comptR2 = 0, comptV2 = 0, comptB2 = 0;
  65. int dragAndDrop = 1;
  66. int positionX, positionY;
  67. int posPieceX, posPieceY;
  68. int posCubeX, posCubeY;
  69. int i, j;
  70. int x, y;
  71. int a1, a2, a3, a4, a5, a6;
  72. int b1, b2, b3, b4, b5, b6;
  73. int c1, c2, c3, c4, c5, c6;
  74. int d1, d2, d3, d4, d5, d6;
  75. int e1, e2, e3, e4, e5, e6;
  76. int f1, f2, f3, f4, f5, f6;
  77. int g1, g2, g3, g4, g5, g6;
  78. int h1, h2, h3, h4, h5, h6;
  79.  
  80. FILE* fichier1 = NULL;
  81. FILE* fichier2 = NULL;
  82. FILE* fichier3 = NULL;
  83. FILE* fichier4 = NULL;
  84. FILE* fichier5 = NULL;
  85. FILE* fichier6 = NULL;
  86.  
  87. SDL_Rect PointHaut[15][15]; //position des points pour la zone de déposition des pions
  88. x = 208;
  89. for (i = 0 ; i < 15 ; i++)
  90. {
  91. y = 25;
  92. for (j = 0 ; j < 15 ; j++)
  93. {
  94. PointHaut[i][j].x = x;
  95. PointHaut[i][j].y = y;
  96.  
  97. fichier1 = fopen("test.txt", "a");
  98. if (fichier1 != NULL)
  99. {
  100. fseek(fichier1, 0, SEEK_END);
  101. fprintf(fichier1, "x%d=%d\ny%d=%d\n\n",i,PointHaut[i][j].x,j,PointHaut[i][j].y);
  102. fclose(fichier1);
  103. }
  104. y+=50;
  105. }
  106. x+=50;
  107. }
  108.  
  109. SDL_Rect PointMid[15][15]; //position des points pour la zone de déposition des pions
  110. x = 158;
  111. for (i = 0 ; i < 15 ; i++)
  112. {
  113. y = 50;
  114. for (j = 0 ; j < 15 ; j++)
  115. {
  116. PointMid[i][j].x = x;
  117. PointMid[i][j].y = y;
  118.  
  119. fichier2 = fopen("test2.txt", "a");
  120. if (fichier2 != NULL)
  121. {
  122. fseek(fichier2, 0, SEEK_END);
  123. fprintf(fichier2, "x=%d\ny=%d\n\n",PointMid[i][j].x,PointMid[i][j].y);
  124. fclose(fichier2);
  125. }
  126. y+=50;
  127. }
  128. x+=50;
  129. }
  130.  
  131. SDL_Rect PointBas[15][15]; //position des points pour la zone de déposition des pions
  132. x = 208;
  133. for (i = 0 ; i < 15 ; i++)
  134. {
  135. y = 75;
  136. for (j = 0 ; j < 15 ; j++)
  137. {
  138. PointBas[i][j].x = x;
  139. PointBas[i][j].y = y;
  140.  
  141. fichier3 = fopen("test3.txt", "a");
  142. if (fichier3 != NULL)
  143. {
  144. fseek(fichier3, 0, SEEK_END);
  145. fprintf(fichier3, "x=%d\ny=%d\n\n",PointBas[i][j].x,PointBas[i][j].y);
  146. fclose(fichier3);
  147. }
  148. y+=50;
  149. }
  150. x+=50;
  151. }
  152.  
  153. SDL_Rect PosCasesJ1off[15][15]; //position que les pieces doivent prendre après dépose
  154. x = 133;
  155. for (i = 0 ; i < 15 ; i++)
  156. {
  157. y = 50;
  158. for (j = 0 ; j < 15 ; j++)
  159. {
  160. PosCasesJ1off[i][j].x = x;
  161. PosCasesJ1off[i][j].y = y;
  162.  
  163. fichier5 = fopen("test5.txt", "a");
  164. if (fichier5 != NULL)
  165. {
  166. fseek(fichier5, 0, SEEK_END);
  167. fprintf(fichier5, "x=%d\ny=%d\n\n",PosCasesJ1off[i][j].x,PosCasesJ1off[i][j].y);
  168. fclose(fichier5);
  169. }
  170. y+=50;
  171. }
  172. x+=50;
  173. }
  174.  
  175. SDL_Rect PosCasesJ1def[15][15]; //position que les pieces doivent prendre après dépose
  176. x = 133;
  177. for (i = 0 ; i < 15 ; i++)
  178. {
  179. y = 45;
  180. for (j = 0 ; j < 15 ; j++)
  181. {
  182. PosCasesJ1def[i][j].x = x;
  183. PosCasesJ1def[i][j].y = y;
  184.  
  185. fichier4 = fopen("test4.txt", "a");
  186. if (fichier4 != NULL)
  187. {
  188. fseek(fichier4, 0, SEEK_END);
  189. fprintf(fichier4, "x=%d\ny=%d\n\n",PosCasesJ1def[i][j].x,PosCasesJ1def[i][j].y);
  190. fclose(fichier4);
  191. }
  192. y+=50;
  193. }
  194. x+=50;
  195. }
  196.  
  197. SDL_Rect PosCasesJ2[15][15]; //position que les pieces doivent prendre après dépose
  198. x = 133;
  199. for (i = 0 ; i < 15 ; i++)
  200. {
  201. y = 0;
  202. for (j = 0 ; j < 15 ; j++)
  203. {
  204. PosCasesJ2[i][j].x = x;
  205. PosCasesJ2[i][j].y = y;
  206.  
  207. fichier6 = fopen("test6.txt", "a");
  208. if (fichier6 != NULL)
  209. {
  210. fseek(fichier6, 0, SEEK_END);
  211. fprintf(fichier6, "x=%d\ny=%d\n\n",PosCasesJ2[i][j].x,PosCasesJ2[i][j].y);
  212. fclose(fichier6);
  213. }
  214. y+=50;
  215. }
  216. x+=50;
  217. }
  218.  
  219. SDL_Init(SDL_INIT_VIDEO);
  220.  
  221. TTF_Init();
  222. if(TTF_Init() == -1)
  223. {
  224. fprintf(stderr, "Erreur d'initialisation de TTF_Init : %s\n", TTF_GetError());
  225. exit(EXIT_FAILURE);
  226. }
  227.  
  228. //On ouvre une fenetre et on vérifie l'ouverture
  229. ecran = SDL_SetVideoMode(1066, 800, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); //SDL_FULLSCREEN
  230. SDL_WM_SetCaption("Jeu dAVVA", NULL);
  231. if (ecran == NULL) // Si l'ouverture a échoué, on écrit l'erreur et on arrête
  232. {
  233. fprintf(stderr, "Impossible de charger le mode vidéo : %s\n", SDL_GetError());
  234. exit(EXIT_FAILURE);
  235. }
  236.  
  237. /* Chargement de l'icone */
  238. SDL_WM_SetIcon(IMG_Load("images/JeuAVVA.bmp"), NULL);
  239.  
  240. //On insere l'image de fond
  241. textureFond = IMG_Load("images/AvvAFond.jpg"); /* Chargement d'une image Bitmap dans une surface */
  242. positionFond.x = 0;
  243. positionFond.y = 0;
  244.  
  245. //on insere l'icone de selection du menu
  246. selectMenu = IMG_Load("images/SelectionMenu.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  247. posSelectMenu.x = 170;
  248. posSelectMenu.y = 200;
  249. SDL_SetColorKey(selectMenu, SDL_SRCCOLORKEY, SDL_MapRGB(selectMenu->format, 255, 255, 255));
  250.  
  251. //On insere touche précédent1
  252. touchePre1 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  253. positionPre1.x = 540;
  254. positionPre1.y = 180;
  255. SDL_SetColorKey(touchePre1, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre1->format, 255, 255, 255));
  256.  
  257. //On insere touche suivante1
  258. toucheSui1 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  259. positionSui1.x = 600;
  260. positionSui1.y = 180;
  261. SDL_SetColorKey(toucheSui1, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui1->format, 255, 255, 255));
  262.  
  263. //On insere touche précédent2
  264. touchePre2 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  265. positionPre2.x = 540;
  266. positionPre2.y = 210;
  267. SDL_SetColorKey(touchePre2, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre2->format, 255, 255, 255));
  268.  
  269. //On insere touche suivante2
  270. toucheSui2 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  271. positionSui2.x = 600;
  272. positionSui2.y = 210;
  273. SDL_SetColorKey(toucheSui2, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui2->format, 255, 255, 255));
  274.  
  275. //On insere touche précédent3
  276. touchePre3 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  277. positionPre3.x = 540;
  278. positionPre3.y = 240;
  279. SDL_SetColorKey(touchePre3, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre3->format, 255, 255, 255));
  280.  
  281. //On insere touche suivante3
  282. toucheSui3 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  283. positionSui3.x = 600;
  284. positionSui3.y = 240;
  285. SDL_SetColorKey(toucheSui3, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui3->format, 255, 255, 255));
  286.  
  287. //On insere touche précédent4
  288. touchePre4 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  289. positionPre4.x = 540;
  290. positionPre4.y = 330;
  291. SDL_SetColorKey(touchePre4, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre4->format, 255, 255, 255));
  292.  
  293. //On insere touche suivante4
  294. toucheSui4 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  295. positionSui4.x = 600;
  296. positionSui4.y = 330;
  297. SDL_SetColorKey(toucheSui4, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui4->format, 255, 255, 255));
  298.  
  299. //On insere touche précédent5
  300. touchePre5 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  301. positionPre5.x = 540;
  302. positionPre5.y = 360;
  303. SDL_SetColorKey(touchePre5, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre5->format, 255, 255, 255));
  304.  
  305. //On insere touche suivante5
  306. toucheSui5 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  307. positionSui5.x = 600;
  308. positionSui5.y = 360;
  309. SDL_SetColorKey(toucheSui5, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui5->format, 255, 255, 255));
  310.  
  311. //On insere touche précédent6
  312. touchePre6 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  313. positionPre6.x = 540;
  314. positionPre6.y = 390;
  315. SDL_SetColorKey(touchePre6, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre6->format, 255, 255, 255));
  316.  
  317. //On insere touche suivante6
  318. toucheSui6 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  319. positionSui6.x = 600;
  320. positionSui6.y = 390;
  321. SDL_SetColorKey(toucheSui6, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui6->format, 255, 255, 255));
  322.  
  323. //On insere touche précédent7
  324. touchePre7 = IMG_Load("images/AvvaPrecedent.bmp"); /* Chargement d'une image Bitmap dans une surface */
  325. positionPre7.x = ecran->w / 2 - touchePre7->w / 2 - 20 ;
  326. positionPre7.y = 480;
  327. SDL_SetColorKey(touchePre7, SDL_SRCCOLORKEY, SDL_MapRGB(touchePre7->format, 255, 255, 255));
  328.  
  329. //On insere touche suivante7
  330. toucheSui7 = IMG_Load("images/AvvaSuivant.bmp"); /* Chargement d'une image Bitmap dans une surface */
  331. positionSui7.x = ecran->w / 2 - toucheSui7->w / 2 + 20 ;
  332. positionSui7.y = 480;
  333. SDL_SetColorKey(toucheSui7, SDL_SRCCOLORKEY, SDL_MapRGB(toucheSui7->format, 255, 255, 255));
  334.  
  335.  
  336.  
  337. /* Chargement du Titre PRINCIPALE = Jeu D'AVVA */
  338. police = TTF_OpenFont("polices/ALGER.TTF", 65);
  339. TTF_SetFontStyle(police, TTF_STYLE_UNDERLINE);
  340. menu = TTF_RenderText_Blended(police, "Jeu D'AVVA", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  341. positionMenu.x = ecran->w / 2 - menu->w / 2;
  342. positionMenu.y = 100;
  343.  
  344. /* Chargement menu 1 = 1 Joueur */
  345. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  346. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  347. menu1 = TTF_RenderText_Blended(police, "1 - 1 Joueur", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  348. positionMenu1.x = ecran->w / 2 - menu1->w / 2;
  349. positionMenu1.y = 200;
  350.  
  351.  
  352. //on insere le carre rouge de slection de piece//
  353. CubikRed = SDL_LoadBMP("images/CarreRouge.bmp");
  354. posCubikRed.x = 0;
  355. posCubikRed.y = 0;
  356. SDL_SetColorKey(CubikRed, SDL_SRCCOLORKEY, SDL_MapRGB(CubikRed->format, 255, 255, 255));
  357. /* Transparence Alpha moyenne (128) : */
  358. SDL_SetAlpha(CubikRed, SDL_SRCALPHA, 128);
  359.  
  360. //on insere le carre rouge de slection de piece//
  361. CubikBlue = SDL_LoadBMP("images/CarreBleu.bmp");
  362. posCubikBlue.x = 0;
  363. posCubikBlue.y = 0;
  364. SDL_SetColorKey(CubikBlue, SDL_SRCCOLORKEY, SDL_MapRGB(CubikBlue->format, 255, 255, 255));
  365. /* Transparence Alpha moyenne (128) : */
  366. SDL_SetAlpha(CubikBlue, SDL_SRCALPHA, 128);
  367.  
  368.  
  369. //On insere touche suivante7
  370. txtDeplaNA = IMG_Load("images/DeplacementNA.JPG"); /* Chargement d'une image Bitmap dans une surface */
  371. posTxtDeplaNA.x = ecran->w / 2 - txtDeplaNA->w / 2;
  372. posTxtDeplaNA.y = 200;
  373.  
  374. /*Chargement titre du sous menu 1joueur*/
  375. police = TTF_OpenFont("polices/ALGER.TTF", 50);
  376. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  377. ssMenu1 = TTF_RenderText_Blended(police, "1 JOUEUR", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  378. positionSsMenu1.x = ecran->w / 2 - ssMenu1->w / 2;
  379. positionSsMenu1.y = 100;
  380.  
  381. //On insere l'image du damier de jeu
  382. damierInc800800NB = IMG_Load("images/Damier800x800DAM.bmp"); /* Chargement d'une image Bitmap dans une surface */
  383. posDamInc800800NB.x = ecran -> w / 2 - damierInc800800NB -> w / 2 ;
  384. posDamInc800800NB.y = 0;
  385. SDL_SetColorKey(damierInc800800NB, SDL_SRCCOLORKEY, SDL_MapRGB(damierInc800800NB->format, 255, 255, 255));
  386.  
  387. //On insere l'image de fond étoile
  388. textureEtoile = IMG_Load("fond/etoile.jpg"); /* Chargement d'une image Bitmap dans une surface */
  389. positionEtoile.x = 0;
  390. positionEtoile.y = 0;
  391.  
  392. //On insere l'image de fond plage
  393. texturePlage = IMG_Load("fond/plage.jpg"); /* Chargement d'une image Bitmap dans une surface */
  394. positionPlage.x = 0;
  395. positionPlage.y = 0;
  396.  
  397. //On insere l'image de fond foret
  398. textureForet = IMG_Load("fond/foret.jpg"); /* Chargement d'une image Bitmap dans une surface */
  399. positionForet.x = 0;
  400. positionForet.y = 0;
  401.  
  402. //On insere l'image de fond nuit
  403. textureNuit = IMG_Load("fond/ciel-nuit.jpg"); /* Chargement d'une image Bitmap dans une surface */
  404. positionNuit.x = 0;
  405. positionNuit.y = 0;
  406.  
  407.  
  408. //On insere l'image JOUEUR 1 COMMENCE
  409. textJ1Commence = IMG_Load("images/Joueur1Commence.JPG"); /* Chargement d'une image Bitmap dans une surface */
  410. posTxtJ1C.x = ecran -> w / 2 - textJ1Commence -> w / 2 ;
  411. posTxtJ1C.y = ecran -> h / 2 - textJ1Commence -> h / 2 ;
  412.  
  413. //on insere la piece offensive NOIR du joueur1
  414. pieceJeuOff1N = IMG_Load("pieces/PieceJeuJ1/Noir/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  415. posPieceJOff1N1.x = 383;
  416. posPieceJOff1N1.y = 650;
  417. posPieceJOff1N2.x = 583;
  418. posPieceJOff1N2.y = 650;
  419. posPieceJOff1N3.x = 433;
  420. posPieceJOff1N3.y = 600;
  421. posPieceJOff1N4.x = 533;
  422. posPieceJOff1N4.y = 600;
  423. posPieceJOff1N5.x = 283;
  424. posPieceJOff1N5.y = 550;
  425. posPieceJOff1N6.x = 683;
  426. posPieceJOff1N6.y = 550;
  427. SDL_SetColorKey(pieceJeuOff1N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceJeuOff1N->format, 255, 255, 255));
  428.  
  429. //on insere la piece defensive NOIR du joueur1
  430. pieceJeuDef1N = IMG_Load("pieces/PieceJeuJ1/Noir/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  431. posPieceJDef1N1.x = 433;
  432. posPieceJDef1N1.y = 695;
  433. posPieceJDef1N2.x = 533;
  434. posPieceJDef1N2.y = 695;
  435. posPieceJDef1N3.x = 483;
  436. posPieceJDef1N3.y = 645;
  437. posPieceJDef1N4.x = 333;
  438. posPieceJDef1N4.y = 595;
  439. posPieceJDef1N5.x = 633;
  440. posPieceJDef1N5.y = 595;
  441. posPieceJDef1N6.x = 483;
  442. posPieceJDef1N6.y = 545;
  443. SDL_SetColorKey(pieceJeuDef1N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceJeuDef1N->format, 255, 255, 255));
  444.  
  445. //on insere la piece offensive Blanc du joueur2
  446. pieceJeuOff2N = IMG_Load("pieces/PieceJeuJ2/Blanc/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  447. posPieceJOff2N1.x = 383;
  448. posPieceJOff2N1.y = 100;
  449. posPieceJOff2N2.x = 583;
  450. posPieceJOff2N2.y = 100;
  451. posPieceJOff2N3.x = 433;
  452. posPieceJOff2N3.y = 150;
  453. posPieceJOff2N4.x = 533;
  454. posPieceJOff2N4.y = 150;
  455. posPieceJOff2N5.x = 283;
  456. posPieceJOff2N5.y = 200;
  457. posPieceJOff2N6.x = 683;
  458. posPieceJOff2N6.y = 200;
  459. SDL_SetColorKey(pieceJeuOff2N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceJeuOff2N->format, 255, 255, 255));
  460.  
  461. //on insere la piece defensive Blanc du joueur2
  462. pieceJeuDef2N = IMG_Load("pieces/PieceJeuJ2/Blanc/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  463. posPieceJDef2N1.x = 433;
  464. posPieceJDef2N1.y = 50;
  465. posPieceJDef2N2.x = 533;
  466. posPieceJDef2N2.y = 50;
  467. posPieceJDef2N3.x = 483;
  468. posPieceJDef2N3.y = 100;
  469. posPieceJDef2N4.x = 333;
  470. posPieceJDef2N4.y = 150;
  471. posPieceJDef2N5.x = 633;
  472. posPieceJDef2N5.y = 150;
  473. posPieceJDef2N6.x = 483;
  474. posPieceJDef2N6.y = 200;
  475. SDL_SetColorKey(pieceJeuDef2N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceJeuDef2N->format, 255, 255, 255));
  476.  
  477.  
  478. /* Chargement du menu 2 - 2 joueurs */
  479. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  480. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  481. menu2 = TTF_RenderText_Blended(police, "2 - 2 Joueurs", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  482. positionMenu2.x = ecran->w / 2 - menu2->w / 2;
  483. positionMenu2.y = 250;
  484.  
  485. /*Chargement titre du sous menu 2joueur*/
  486. police = TTF_OpenFont("polices/ALGER.TTF", 50);
  487. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  488. ssMenu2 = TTF_RenderText_Blended(police, "2 JOUEURS", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  489. positionSsMenu2.x = ecran->w / 2 - ssMenu2->w / 2;
  490. positionSsMenu2.y = 100;
  491.  
  492. /* Chargement menu 3 - Charger une partie */
  493. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  494. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  495. menu3 = TTF_RenderText_Blended(police, "3 - Charger une partie", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  496. positionMenu3.x = ecran->w / 2 - menu3->w / 2;
  497. positionMenu3.y = 300;
  498.  
  499. /*Chargement titre du sous menu 3 - charger une partie*/
  500. police = TTF_OpenFont("polices/ALGER.TTF", 50);
  501. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  502. ssMenu3 = TTF_RenderText_Blended(police, "Charger une partie", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  503. positionSsMenu3.x = ecran->w / 2 - ssMenu3->w / 2;
  504. positionSsMenu3.y = 100;
  505.  
  506. /* Chargement menu 4 - revoir une partie */
  507. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  508. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  509. menu4 = TTF_RenderText_Blended(police, "4 - Revoir une partie", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  510. positionMenu4.x = ecran->w / 2 - menu4->w / 2;
  511. positionMenu4.y = 350;
  512.  
  513. /*Chargement titre du sous menu 4 - revoir une partie*/
  514. police = TTF_OpenFont("polices/ALGER.TTF", 50);
  515. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  516. ssMenu4 = TTF_RenderText_Blended(police, "Revoir une partie", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  517. positionSsMenu4.x = ecran->w / 2 - ssMenu4->w / 2;
  518. positionSsMenu4.y = 100;
  519.  
  520. /* Chargement titre du sous menu 4 - Selectionner une partie a revoir */
  521. police = TTF_OpenFont("polices/TIMES.TTF", 15);
  522. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  523. texteSelect = TTF_RenderText_Blended(police, "Selectionner une partie à revoir", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  524. posTexteSelect.x = ecran->w / 2 - texteSelect->w / 2;
  525. posTexteSelect.y = 200;
  526.  
  527. /* Chargement et du menu 5 - option */
  528. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  529. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  530. menu5 = TTF_RenderText_Blended(police, "5 - Options", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  531. positionMenu5.x = ecran->w / 2 - menu5->w / 2;
  532. positionMenu5.y = 400;
  533.  
  534. /* Chargement titre sous menu 5 - option */
  535. police = TTF_OpenFont("polices/ALGER.TTF", 50);
  536. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  537. ssMenu5 = TTF_RenderText_Blended(police, "Options", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  538. positionSsMenu5.x = ecran->w / 2 - ssMenu5->w / 2;
  539. positionSsMenu5.y = 100;
  540.  
  541. /* Sous menu option/changer la couleur des pieces */
  542. police = TTF_OpenFont("polices/ALGER.TTF", 30);
  543. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  544. textureDamier = TTF_RenderText_Blended(police, "Changer la couleur des pieces", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  545. positionTextureD.x = ecran->w / 2 - textureDamier->w / 2;
  546. positionTextureD.y = 200;
  547.  
  548. //on insere la piece offensive NOIR du joueur1
  549. pieceOff1N = IMG_Load("pieces/Joueur1/Noir/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  550. posPieceOff1N.x = 200;
  551. posPieceOff1N.y = 200;
  552. SDL_SetColorKey(pieceOff1N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1N->format, 255, 255, 255));
  553.  
  554. //on insere la piece defensive NOIR du joueur1
  555. pieceDef1N = IMG_Load("pieces/Joueur1/Noir/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  556. posPieceDef1N.x = 350;
  557. posPieceDef1N.y = 193;
  558. SDL_SetColorKey(pieceDef1N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1N->format, 255, 255, 255));
  559.  
  560. //on insere la piece offensive NOIR du joueur2
  561. pieceOff2N = IMG_Load("pieces/Joueur2/Noir/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  562. posPieceOff2N.x = 200;
  563. posPieceOff2N.y = 340;
  564. SDL_SetColorKey(pieceOff2N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2N->format, 255, 255, 255));
  565.  
  566. //on insere la piece defensive NOIR du joueur2
  567. pieceDef2N = IMG_Load("pieces/Joueur2/Noir/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  568. posPieceDef2N.x = 350;
  569. posPieceDef2N.y = 340;
  570. SDL_SetColorKey(pieceDef2N, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2N->format, 255, 255, 255));
  571.  
  572. //on insere la piece offensive BLANC du joueur1
  573. pieceOff1B = IMG_Load("pieces/Joueur1/Blanc/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  574. posPieceOff1B.x = 200;
  575. posPieceOff1B.y = 200;
  576. SDL_SetColorKey(pieceOff1B, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1B->format, 255, 255, 255));
  577.  
  578. //on insere la piece defensive BLANC du joueur1
  579. pieceDef1B = IMG_Load("pieces/Joueur1/Blanc/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  580. posPieceDef1B.x = 350;
  581. posPieceDef1B.y = 193;
  582. SDL_SetColorKey(pieceDef1B, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1B->format, 255, 255, 255));
  583.  
  584. //on insere la piece offensive BLANC du joueur2
  585. pieceOff2B = IMG_Load("pieces/Joueur2/Blanc/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  586. posPieceOff2B.x = 200;
  587. posPieceOff2B.y = 340;
  588. SDL_SetColorKey(pieceOff2B, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2B->format, 255, 255, 255));
  589.  
  590. //on insere la piece defensive BLANC du joueur2
  591. pieceDef2B = IMG_Load("pieces/Joueur2/Blanc/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  592. posPieceDef2B.x = 350;
  593. posPieceDef2B.y = 340;
  594. SDL_SetColorKey(pieceDef2B, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2B->format, 255, 255, 255));
  595.  
  596. //on insere la piece offensive ROUGE du joueur1
  597. pieceOff1R = IMG_Load("pieces/Joueur1/Rouge/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  598. posPieceOff1R.x = 200;
  599. posPieceOff1R.y = 200;
  600. SDL_SetColorKey(pieceOff1R, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1R->format, 255, 255, 255));
  601.  
  602. //on insere la piece defensive ROUGE du joueur1
  603. pieceDef1R = IMG_Load("pieces/Joueur1/Rouge/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  604. posPieceDef1R.x = 350;
  605. posPieceDef1R.y = 193;
  606. SDL_SetColorKey(pieceDef1R, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1R->format, 255, 255, 255));
  607.  
  608. //on insere la piece offensive ROUGE du joueur2
  609. pieceOff2R = IMG_Load("pieces/Joueur2/Rouge/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  610. posPieceOff2R.x = 200;
  611. posPieceOff2R.y = 340;
  612. SDL_SetColorKey(pieceOff2R, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2R->format, 255, 255, 255));
  613.  
  614. //on insere la piece defensive ROUGE du joueur2
  615. pieceDef2R = IMG_Load("pieces/Joueur2/Rouge/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  616. posPieceDef2R.x = 350;
  617. posPieceDef2R.y = 340;
  618. SDL_SetColorKey(pieceDef2R, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2R->format, 255, 255, 255));
  619.  
  620. //on insere la piece offensive VERT du joueur1
  621. pieceOff1V = IMG_Load("pieces/Joueur1/Vert/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  622. posPieceOff1V.x = 200;
  623. posPieceOff1V.y = 200;
  624. SDL_SetColorKey(pieceOff1V, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1V->format, 255, 255, 255));
  625.  
  626. //on insere la piece defensive VERT du joueur1
  627. pieceDef1V = IMG_Load("pieces/Joueur1/Vert/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  628. posPieceDef1V.x = 350;
  629. posPieceDef1V.y = 193;
  630. SDL_SetColorKey(pieceDef1V, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1V->format, 255, 255, 255));
  631.  
  632. //on insere la piece offensive VERT du joueur2
  633. pieceOff2V = IMG_Load("pieces/Joueur2/Vert/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  634. posPieceOff2V.x = 200;
  635. posPieceOff2V.y = 340;
  636. SDL_SetColorKey(pieceOff2V, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2V->format, 255, 255, 255));
  637.  
  638. //on insere la piece defensive VERT du joueur2
  639. pieceDef2V = IMG_Load("pieces/Joueur2/Vert/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  640. posPieceDef2V.x = 350;
  641. posPieceDef2V.y = 340;
  642. SDL_SetColorKey(pieceDef2V, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2V->format, 255, 255, 255));
  643.  
  644. //on insere la piece offensive BLEU du joueur1
  645. pieceOff1Bl = IMG_Load("pieces/Joueur1/Bleu/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  646. posPieceOff1Bl.x = 200;
  647. posPieceOff1Bl.y = 200;
  648. SDL_SetColorKey(pieceOff1Bl, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1Bl->format, 255, 255, 255));
  649.  
  650. //on insere la piece defensive BLEU du joueur1
  651. pieceDef1Bl = IMG_Load("pieces/Joueur1/Bleu/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  652. posPieceDef1Bl.x = 350;
  653. posPieceDef1Bl.y = 193;
  654. SDL_SetColorKey(pieceDef1Bl, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1Bl->format, 255, 255, 255));
  655.  
  656. //on insere la piece offensive BLEU du joueur2
  657. pieceOff2Bl = IMG_Load("pieces/Joueur2/Bleu/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  658. posPieceOff2Bl.x = 200;
  659. posPieceOff2Bl.y = 340;
  660. SDL_SetColorKey(pieceOff2Bl, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2Bl->format, 255, 255, 255));
  661.  
  662. //on insere la piece defensive BLEU du joueur2
  663. pieceDef2Bl = IMG_Load("pieces/Joueur2/Bleu/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  664. posPieceDef2Bl.x = 350;
  665. posPieceDef2Bl.y = 340;
  666. SDL_SetColorKey(pieceDef2Bl, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2Bl->format, 255, 255, 255));
  667.  
  668. //on insere la piece offensive JAUNE du joueur1
  669. pieceOff1J = IMG_Load("pieces/Joueur1/Jaune/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  670. posPieceOff1J.x = 200;
  671. posPieceOff1J.y = 200;
  672. SDL_SetColorKey(pieceOff1J, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1J->format, 255, 255, 255));
  673.  
  674. //on insere la piece defensive JAUNE du joueur1
  675. pieceDef1J = IMG_Load("pieces/Joueur1/Jaune/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  676. posPieceDef1J.x = 350;
  677. posPieceDef1J.y = 193;
  678. SDL_SetColorKey(pieceDef1J, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1J->format, 255, 255, 255));
  679.  
  680. //on insere la piece offensive JAUNE du joueur2
  681. pieceOff2J = IMG_Load("pieces/Joueur2/Jaune/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  682. posPieceOff2J.x = 200;
  683. posPieceOff2J.y = 340;
  684. SDL_SetColorKey(pieceOff2J, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2J->format, 255, 255, 255));
  685.  
  686. //on insere la piece defensive JAUNE du joueur2
  687. pieceDef2J = IMG_Load("pieces/Joueur2/Jaune/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  688. posPieceDef2J.x = 350;
  689. posPieceDef2J.y = 340;
  690. SDL_SetColorKey(pieceDef2J, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2J->format, 255, 255, 255));
  691.  
  692. //on insere la piece offensive CYAN du joueur1
  693. pieceOff1C = IMG_Load("pieces/Joueur1/Cyan/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  694. posPieceOff1C.x = 200;
  695. posPieceOff1C.y = 200;
  696. SDL_SetColorKey(pieceOff1C, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1C->format, 255, 255, 255));
  697.  
  698. //on insere la piece defensive CYAN du joueur1
  699. pieceDef1C = IMG_Load("pieces/Joueur1/Cyan/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  700. posPieceDef1C.x = 350;
  701. posPieceDef1C.y = 193;
  702. SDL_SetColorKey(pieceDef1C, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1C->format, 255, 255, 255));
  703.  
  704. //on insere la piece offensive CYAN du joueur2
  705. pieceOff2C = IMG_Load("pieces/Joueur2/Cyan/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  706. posPieceOff2C.x = 200;
  707. posPieceOff2C.y = 340;
  708. SDL_SetColorKey(pieceOff2C, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2C->format, 255, 255, 255));
  709.  
  710. //on insere la piece defensive CYAN du joueur2
  711. pieceDef2C = IMG_Load("pieces/Joueur2/Cyan/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  712. posPieceDef2C.x = 350;
  713. posPieceDef2C.y = 340;
  714. SDL_SetColorKey(pieceDef2C, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2C->format, 255, 255, 255));
  715.  
  716. //on insere la piece offensive MAGENTA du joueur1
  717. pieceOff1M = IMG_Load("pieces/Joueur1/Magenta/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  718. posPieceOff1M.x = 200;
  719. posPieceOff1M.y = 200;
  720. SDL_SetColorKey(pieceOff1M, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff1M->format, 255, 255, 255));
  721.  
  722. //on insere la piece defensive MAGENTA du joueur1
  723. pieceDef1M = IMG_Load("pieces/Joueur1/Magenta/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  724. posPieceDef1M.x = 350;
  725. posPieceDef1M.y = 193;
  726. SDL_SetColorKey(pieceDef1M, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef1M->format, 255, 255, 255));
  727.  
  728. //on insere la piece offensive MAGENTA du joueur2
  729. pieceOff2M = IMG_Load("pieces/Joueur2/Magenta/pieceOff.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  730. posPieceOff2M.x = 200;
  731. posPieceOff2M.y = 340;
  732. SDL_SetColorKey(pieceOff2M, SDL_SRCCOLORKEY, SDL_MapRGB(pieceOff2M->format, 255, 255, 255));
  733.  
  734. //on insere la piece defensive MAGENTA du joueur2
  735. pieceDef2M = IMG_Load("pieces/Joueur2/Magenta/pieceDef.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  736. posPieceDef2M.x = 350;
  737. posPieceDef2M.y = 340;
  738. SDL_SetColorKey(pieceDef2M, SDL_SRCCOLORKEY, SDL_MapRGB(pieceDef2M->format, 255, 255, 255));
  739.  
  740. //On insere le carreRouge1
  741. carreRouge1 = IMG_Load("images/carreRouge.JPG"); /* Chargement d'une image Bitmap dans une surface */
  742. posCarreRouge1.x = 570;
  743. posCarreRouge1.y = 185;
  744.  
  745. //On insere le carreVert1
  746. carreVert1 = IMG_Load("images/carreVert.JPG"); /* Chargement d'une image Bitmap dans une surface */
  747. posCarreVert1.x = 570;
  748. posCarreVert1.y = 215;
  749.  
  750. //On insere le carreBleu1
  751. carreBleu1 = IMG_Load("images/carreBleu.JPG"); /* Chargement d'une image Bitmap dans une surface */
  752. posCarreBleu1.x = 570;
  753. posCarreBleu1.y = 245;
  754.  
  755. //On insere le carreRouge2
  756. carreRouge2 = IMG_Load("images/carreRouge.JPG"); /* Chargement d'une image Bitmap dans une surface */
  757. posCarreRouge2.x = 570;
  758. posCarreRouge2.y = 335;
  759.  
  760. //On insere le carreVert2
  761. carreVert2 = IMG_Load("images/carreVert.JPG"); /* Chargement d'une image Bitmap dans une surface */
  762. posCarreVert2.x = 570;
  763. posCarreVert2.y = 365;
  764.  
  765. //On insere le carreBleu2
  766. carreBleu2 = IMG_Load("images/carreBleu.JPG"); /* Chargement d'une image Bitmap dans une surface */
  767. posCarreBleu2.x = 570;
  768. posCarreBleu2.y = 395;
  769.  
  770. //On insere le 0 rouge
  771. rouge0 = IMG_Load("images/rouge0.bmp"); /* Chargement d'une image Bitmap dans une surface */
  772. posRouge0A.x = 520;
  773. posRouge0A.y = 185;
  774. posRouge0B.x = 520;
  775. posRouge0B.y = 335;
  776. SDL_SetColorKey(rouge0, SDL_SRCCOLORKEY, SDL_MapRGB(rouge0->format, 255, 255, 255));
  777.  
  778. //On insere le 1 rouge
  779. rouge1 = IMG_Load("images/rouge1.bmp"); /* Chargement d'une image Bitmap dans une surface */
  780. posRouge1A.x = 630;
  781. posRouge1A.y = 185;
  782. posRouge1B.x = 630;
  783. posRouge1B.y = 335;
  784. SDL_SetColorKey(rouge1, SDL_SRCCOLORKEY, SDL_MapRGB(rouge1->format, 255, 255, 255));
  785.  
  786. //On insere le 0 vert
  787. vert0 = IMG_Load("images/vert0.bmp"); /* Chargement d'une image Bitmap dans une surface */
  788. posVert0A.x = 520;
  789. posVert0A.y = 215;
  790. posVert0B.x = 520;
  791. posVert0B.y = 365;
  792. SDL_SetColorKey(vert0, SDL_SRCCOLORKEY, SDL_MapRGB(vert0->format, 255, 255, 255));
  793.  
  794. //On insere le 1 vert
  795. vert1 = IMG_Load("images/vert1.bmp"); /* Chargement d'une image Bitmap dans une surface */
  796. posVert1A.x = 630;
  797. posVert1A.y = 215;
  798. posVert1B.x = 630;
  799. posVert1B.y = 365;
  800. SDL_SetColorKey(vert1, SDL_SRCCOLORKEY, SDL_MapRGB(vert1->format, 255, 255, 255));
  801.  
  802. //On insere le 0 bleu
  803. bleu0 = IMG_Load("images/bleu0.bmp"); /* Chargement d'une image Bitmap dans une surface */
  804. posBleu0A.x = 520;
  805. posBleu0A.y = 245;
  806. posBleu0B.x = 520;
  807. posBleu0B.y = 395;
  808. SDL_SetColorKey(bleu0, SDL_SRCCOLORKEY, SDL_MapRGB(bleu0->format, 255, 255, 255));
  809.  
  810. //On insere le 1 bleu
  811. bleu1 = IMG_Load("images/bleu1.bmp"); /* Chargement d'une image Bitmap dans une surface */
  812. posBleu1A.x = 630;
  813. posBleu1A.y = 245;
  814. posBleu1B.x = 630;
  815. posBleu1B.y = 395;
  816. SDL_SetColorKey(bleu1, SDL_SRCCOLORKEY, SDL_MapRGB(bleu1->format, 255, 255, 255));
  817.  
  818. /* Sous menu option/changer le fond */
  819. police = TTF_OpenFont("polices/ALGER.TTF", 30);
  820. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  821. textureDeFond = TTF_RenderText_Blended(police, "Changer la texture de fond", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  822. positionTextureF.x = ecran->w / 2 - textureDeFond->w / 2;
  823. positionTextureF.y = 250;
  824.  
  825. /* Sous menu option/changer de fond Titre : texture */
  826. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  827. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  828. txtTexture = TTF_RenderText_Blended(police, "Texture", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  829. posTxtTexture.x = ecran->w / 2 - txtTexture->w / 2;
  830. posTxtTexture.y = 100;
  831.  
  832. //On insere l'image de fond dans le menu selection du fond
  833. textureDamFond = IMG_Load("fond/AvvA2.jpg"); /* Chargement d'une image Bitmap dans une surface */
  834. positionDamFond.x = ecran->w / 2 - textureDamFond->w / 2;
  835. positionDamFond.y = 150;
  836.  
  837. //On insere l'image de fond étoile
  838. textureEtoile2 = IMG_Load("fond/etoile2.jpg"); /* Chargement d'une image Bitmap dans une surface */
  839. positionEtoile2.x = ecran->w / 2 - textureEtoile2->w / 2;
  840. positionEtoile2.y = 150;
  841.  
  842. //On insere l'image de fond nuit
  843. textureNuit2 = IMG_Load("fond/ciel-nuit2.jpg"); /* Chargement d'une image Bitmap dans une surface */
  844. positionNuit2.x = ecran->w / 2 - textureNuit2->w / 2;
  845. positionNuit2.y = 150;
  846.  
  847. //On insere l'image de fond plage
  848. texturePlage2 = IMG_Load("fond/plage2.jpg"); /* Chargement d'une image Bitmap dans une surface */
  849. positionPlage2.x = ecran->w / 2 - texturePlage2->w / 2;
  850. positionPlage2.y = 150;
  851.  
  852. //On insere l'image de fond foret
  853. textureForet2 = IMG_Load("fond/Foret2.jpg"); /* Chargement d'une image Bitmap dans une surface */
  854. positionForet2.x = ecran->w / 2 - textureForet2->w / 2;
  855. positionForet2.y = 150;
  856.  
  857. //on insere le damier incliner dans le menu option changer les fonds
  858. damierInc400400NB = IMG_Load("images/Damier400x400NB.bmp"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  859. posDamInc400400VB.x = ecran->w / 2 - damierInc400400NB->w / 2;
  860. posDamInc400400VB.y = 170;
  861. SDL_SetColorKey(damierInc400400NB, SDL_SRCCOLORKEY, SDL_MapRGB(damierInc400400NB->format, 255, 255, 255));
  862.  
  863. /* Sous menu option/Réglage du volume */
  864. police = TTF_OpenFont("polices/ALGER.TTF", 30);
  865. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  866. reglageVol = TTF_RenderText_Blended(police, "Reglage du volume", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  867. positionReglageV.x = ecran->w / 2 - reglageVol->w / 2;
  868. positionReglageV.y = 300;
  869.  
  870. /* Sous menu option/ Titre :Réglage du volume */
  871. police = TTF_OpenFont("polices/ALGER.TTF", 30);
  872. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  873. txtRegDuVol = TTF_RenderText_Blended(police, "Reglage du volume", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  874. posTxtReglageV.x = ecran->w / 2 - txtRegDuVol->w / 2;
  875. posTxtReglageV.y = 100;
  876.  
  877. //on insere l'icone barre du volume
  878. selectVolume = IMG_Load("images/barreVol.png"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  879. posSelectVol.x = ecran ->w / 2 - selectVolume->w / 2 + 2;
  880. posSelectVol.y = 200;
  881. SDL_SetColorKey(selectVolume, SDL_SRCCOLORKEY, SDL_MapRGB(selectVolume->format, 255, 255, 255));
  882.  
  883. //on insere l'icone bouton du volume
  884. selectBoutonVol = IMG_Load("images/boutonVol.png"); /* Chargement et blittage de l'icone de selection menu sur la scène */
  885. posBoutonVol.x = ecran ->w / 2 - selectBoutonVol->w / 2 ;
  886. posBoutonVol.y = 195;
  887. SDL_SetColorKey(selectBoutonVol, SDL_SRCCOLORKEY, SDL_MapRGB(selectBoutonVol->format, 255, 255, 255));
  888.  
  889.  
  890. /* Chargement du menu 6 - Règle du Jeu*/
  891. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  892. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  893. menu6 = TTF_RenderText_Blended(police, "6 - Règle du jeu", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  894. positionMenu6.x = ecran->w / 2 - menu6->w / 2;
  895. positionMenu6.y = 450;
  896.  
  897. /* Chargement du menu 6 - Règle du Jeu*/
  898. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  899. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  900. ssMenu6 = TTF_RenderText_Blended(police, "Règle du jeu", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  901. positionSsMenu6.x = ecran->w / 2 - ssMenu6->w / 2;
  902. positionSsMenu6.y = 100;
  903.  
  904. //On insere la regle du jeu 1
  905. regleJeu1 = IMG_Load("images/regles/regle1.bmp"); // Chargement d'une image Bitmap dans une surface //
  906. posRegleJeu1.x = ecran->w / 2 - regleJeu1->w / 2;
  907. posRegleJeu1.y = 150;
  908.  
  909. //On insere la regle du jeu 2
  910. regleJeu2 = IMG_Load("images/regles/regle2.bmp"); // Chargement d'une image Bitmap dans une surface //
  911. posRegleJeu2.x = ecran->w / 2 - regleJeu2->w / 2;
  912. posRegleJeu2.y = 150;
  913.  
  914. //On insere la regle du jeu 3
  915. regleJeu3 = IMG_Load("images/regles/regle3.bmp"); // Chargement d'une image Bitmap dans une surface //
  916. posRegleJeu3.x = ecran->w / 2 - regleJeu3->w / 2;
  917. posRegleJeu3.y = 150;
  918.  
  919. //On insere la regle du jeu 4
  920. regleJeu4 = IMG_Load("images/regles/regle4.bmp"); // Chargement d'une image Bitmap dans une surface //
  921. posRegleJeu4.x = ecran->w / 2 - regleJeu4->w / 2;
  922. posRegleJeu4.y = 150;
  923.  
  924. //On insere la regle du jeu 5
  925. regleJeu5 = IMG_Load("images/regles/regle5.bmp"); // Chargement d'une image Bitmap dans une surface //
  926. posRegleJeu5.x = ecran->w / 2 - regleJeu5->w / 2;
  927. posRegleJeu5.y = 150;
  928.  
  929. //On insere la regle du jeu 6
  930. regleJeu6 = IMG_Load("images/regles/regle6.bmp"); // Chargement d'une image Bitmap dans une surface //
  931. posRegleJeu6.x = ecran->w / 2 - regleJeu6->w / 2;
  932. posRegleJeu6.y = 150;
  933.  
  934. //On insere la regle du jeu 7
  935. regleJeu7 = IMG_Load("images/regles/regle7.bmp"); // Chargement d'une image Bitmap dans une surface //
  936. posRegleJeu7.x = ecran->w / 2 - regleJeu7->w / 2;
  937. posRegleJeu7.y = 150;
  938.  
  939. /* Chargement du menu 7 - Exit*/
  940. police = TTF_OpenFont("polices/ALGER.TTF", 35);
  941. TTF_SetFontStyle(police,TTF_STYLE_NORMAL);
  942. menu7 = TTF_RenderText_Blended(police, "7 - Exit (or press esc)", couleurNoire);/* Ecriture du texte dans la SDL_Surface "texte" en mode Blended (optimal) */
  943. positionMenu7.x = ecran->w / 2 - menu7->w / 2;
  944. positionMenu7.y = 500;
  945.  
  946.  
  947.  
  948. /* Activation de la répétition au clavier */
  949. SDL_EnableKeyRepeat(400, 5);
  950.  
  951.  
  952. while (continuer) /* TANT QUE la variable ne vaut pas 0, on répète la page du menu principale, continuer vaut 0 quand on fait echap ou "enter" sur "exit" du menu*/
  953. {
  954. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  955. switch(event.type) /* On teste le type d'évènement */
  956. {
  957. case SDL_QUIT: /* Si c'est un évènement QUITTER - le croix dans le coin supérieur droit */
  958. continuer = 0; /* On met continuer à 0, donc la boucle va s'arrêter et le programme s'arrête*/
  959. break;
  960.  
  961. case SDL_KEYDOWN:
  962. switch (event.key.keysym.sym)
  963. {
  964. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  965. continuer = 0;
  966. break;
  967.  
  968. case SDLK_UP: // Flèche haut
  969. if(posSelectMenu.y >=250)
  970. {
  971. posSelectMenu.y = posSelectMenu.y-50;
  972. break;
  973. }
  974. break;
  975.  
  976. case SDLK_DOWN: // Flèche bas
  977. if (posSelectMenu.y <=450)
  978. {
  979. posSelectMenu.y = posSelectMenu.y+50;
  980. break;
  981. }
  982. break;
  983.  
  984. case SDLK_RETURN: //Touche entrer
  985. while (continuer)
  986. {
  987. //quand le pointeur est sur 1 joueur
  988. if (posSelectMenu.y >=0 && posSelectMenu.y<250)
  989. {
  990. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  991. {
  992. dragAndDrop = 1;
  993. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  994. switch(event.type) /* On teste le type d'évènement */
  995. {
  996. case SDL_KEYDOWN:
  997. switch(event.key.keysym.sym)
  998. {
  999. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  1000. continuer1 = 0;
  1001. default:
  1002. break;
  1003. }
  1004. break;
  1005.  
  1006. case SDL_MOUSEBUTTONDOWN:
  1007.  
  1008. for(i=0 ; i<15 ; i++)
  1009. {
  1010. for(j=0 ; j<15 ; j++)
  1011. {
  1012. if (PosCasesJ1off[i][j].x == posPieceJOff1N1.x && PosCasesJ1off[i][j].y == posPieceJOff1N1.y)
  1013. {
  1014. a1=i;
  1015. b1=j;
  1016. }
  1017. else if (PosCasesJ1off[i][j].x == posPieceJOff1N2.x && PosCasesJ1off[i][j].y == posPieceJOff1N2.y)
  1018. {
  1019. a2=i;
  1020. b2=j;
  1021. }
  1022. else if (PosCasesJ1off[i][j].x == posPieceJOff1N3.x && PosCasesJ1off[i][j].y == posPieceJOff1N3.y)
  1023. {
  1024. a3=i;
  1025. b3=j;
  1026. }
  1027. else if (PosCasesJ1off[i][j].x == posPieceJOff1N4.x && PosCasesJ1off[i][j].y == posPieceJOff1N4.y)
  1028. {
  1029. a4=i;
  1030. b4=j;
  1031. }
  1032. else if (PosCasesJ1off[i][j].x == posPieceJOff1N5.x && PosCasesJ1off[i][j].y == posPieceJOff1N5.y)
  1033. {
  1034. a5=i;
  1035. b5=j;
  1036. }
  1037. else if (PosCasesJ1off[i][j].x == posPieceJOff1N6.x && PosCasesJ1off[i][j].y == posPieceJOff1N6.y)
  1038. {
  1039. a6=i;
  1040. b6=j;
  1041. }
  1042. else if (PosCasesJ1def[i][j].x == posPieceJDef1N1.x && PosCasesJ1def[i][j].y == posPieceJDef1N1.y)
  1043. {
  1044. c1=i;
  1045. d1=j;
  1046. }
  1047. else if (PosCasesJ1def[i][j].x == posPieceJDef1N2.x && PosCasesJ1def[i][j].y == posPieceJDef1N2.y)
  1048. {
  1049. c2=i;
  1050. d2=j;
  1051. }
  1052. else if (PosCasesJ1def[i][j].x == posPieceJDef1N3.x && PosCasesJ1def[i][j].y == posPieceJDef1N3.y)
  1053. {
  1054. c3=i;
  1055. d3=j;
  1056. }
  1057. else if (PosCasesJ1def[i][j].x == posPieceJDef1N4.x && PosCasesJ1def[i][j].y == posPieceJDef1N4.y)
  1058. {
  1059. c4=i;
  1060. d4=j;
  1061. }
  1062. else if (PosCasesJ1def[i][j].x == posPieceJDef1N5.x && PosCasesJ1def[i][j].y == posPieceJDef1N5.y)
  1063. {
  1064. c5=i;
  1065. d5=j;
  1066. }
  1067. else if (PosCasesJ1def[i][j].x == posPieceJDef1N6.x && PosCasesJ1def[i][j].y == posPieceJDef1N6.y)
  1068. {
  1069. c6=i;
  1070. d6=j;
  1071. }
  1072. else if (PosCasesJ2[i][j].x == posPieceJOff2N1.x && PosCasesJ2[i][j].y == posPieceJOff2N1.y)
  1073. {
  1074. e1=i;
  1075. f1=j;
  1076. }
  1077. else if (PosCasesJ2[i][j].x == posPieceJOff2N2.x && PosCasesJ2[i][j].y == posPieceJOff2N2.y)
  1078. {
  1079. e2=i;
  1080. f2=j;
  1081. }
  1082. else if (PosCasesJ2[i][j].x == posPieceJOff2N3.x && PosCasesJ2[i][j].y == posPieceJOff2N3.y)
  1083. {
  1084. e3=i;
  1085. f3=j;
  1086. }
  1087. else if (PosCasesJ2[i][j].x == posPieceJOff2N4.x && PosCasesJ2[i][j].y == posPieceJOff2N4.y)
  1088. {
  1089. e4=i;
  1090. f4=j;
  1091. }
  1092. else if (PosCasesJ2[i][j].x == posPieceJOff2N5.x && PosCasesJ2[i][j].y == posPieceJOff2N5.y)
  1093. {
  1094. e5=i;
  1095. f5=j;
  1096. }
  1097. else if (PosCasesJ2[i][j].x == posPieceJOff2N6.x && PosCasesJ2[i][j].y == posPieceJOff2N6.y)
  1098. {
  1099. e6=i;
  1100. f6=j;
  1101. }
  1102. else if (PosCasesJ2[i][j].x == posPieceJDef2N1.x && PosCasesJ2[i][j].y == posPieceJDef2N1.y)
  1103. {
  1104. g1=i;
  1105. h1=j;
  1106. }
  1107. else if (PosCasesJ2[i][j].x == posPieceJDef2N2.x && PosCasesJ2[i][j].y == posPieceJDef2N2.y)
  1108. {
  1109. g2=i;
  1110. h2=j;
  1111. }
  1112. else if (PosCasesJ2[i][j].x == posPieceJDef2N3.x && PosCasesJ2[i][j].y == posPieceJDef2N3.y)
  1113. {
  1114. g3=i;
  1115. h3=j;
  1116. }
  1117. else if (PosCasesJ2[i][j].x == posPieceJDef2N4.x && PosCasesJ2[i][j].y == posPieceJDef2N4.y)
  1118. {
  1119. g4=i;
  1120. h4=j;
  1121. }
  1122. else if (PosCasesJ2[i][j].x == posPieceJDef2N5.x && PosCasesJ2[i][j].y == posPieceJDef2N5.y)
  1123. {
  1124. g5=i;
  1125. h5=j;
  1126. }
  1127. else if (PosCasesJ2[i][j].x == posPieceJDef2N6.x && PosCasesJ2[i][j].y == posPieceJDef2N6.y)
  1128. {
  1129. g6=i;
  1130. h6=j;
  1131. }
  1132. }
  1133. }
  1134. if (event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a1][b1].x && event.motion.x <= PointBas[a1][b1].x && event.motion.y >= PointMid[a1][b1].y && event.motion.y <= PointBas[a1][b1].y && posPieceJOff1N1.x == PosCasesJ1off[a1][b1].x && posPieceJOff1N1.y == PosCasesJ1off[a1][b1].y)
  1135. //if (event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[5][12].x && event.motion.x <= PointBas[5][12].x && event.motion.y >= PointMid[5][12].y && event.motion.y <= PointBas[5][12].y && posPieceJOff1N1.x == PosCasesJ1off[5][12].x && posPieceJOff1N1.y == PosCasesJ1off[5][12].y)//
  1136. {
  1137. while (dragAndDrop)
  1138. {
  1139. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1140. posPieceX = posPieceJOff1N1.x;
  1141. posCubikRed.x = posPieceX;
  1142. posCubeX = posCubikRed.x;
  1143.  
  1144.  
  1145. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1146. posPieceY = posPieceJOff1N1.y;
  1147. posCubikRed.y = posPieceY-50;
  1148. posCubeY = posCubikRed.y;
  1149.  
  1150. /*if(positionX > posPieceX && positionY == posPieceY)
  1151. {
  1152. posCubikRed.x = posCubikRed.x+100;
  1153. posPieceJOff1N1.x = posPieceJOff1N1.x+100;
  1154. }*/
  1155. /*else*/ if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1156. {
  1157. posCubikRed.x = posCubikRed.x+50;
  1158. posPieceJOff1N1.x = posPieceJOff1N1.x+50;
  1159.  
  1160. posCubikRed.y = posCubikRed.y+50;
  1161. posPieceJOff1N1.y = posPieceJOff1N1.y+50;
  1162. }
  1163. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1164. {
  1165. posCubikRed.x = posCubikRed.x+50;
  1166. posPieceJOff1N1.x = posPieceJOff1N1.x+50;
  1167.  
  1168. posCubikRed.y = posCubikRed.y-50;
  1169. posPieceJOff1N1.y = posPieceJOff1N1.y-50;
  1170. }
  1171.  
  1172. /*else if(positionX == posPieceX && positionY > posPieceY)
  1173. {
  1174. posCubikRed.y = posCubikRed.y+100;
  1175. posPieceJOff1N1.y = posPieceJOff1N1.y+100;
  1176. }
  1177. else if(positionX == posPieceX && positionY < posPieceY)
  1178. {
  1179. posCubikRed.y = positionY-100;
  1180. posPieceJOff1N1.y = positionY-100;
  1181. }
  1182.  
  1183. else if(positionX < posPieceX && positionY == posPieceY)
  1184. {
  1185. posCubikRed.x = posCubikRed.x-100;
  1186. posPieceJOff1N1.x = posPieceJOff1N1.x-100;
  1187. }*/
  1188. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1189. {
  1190. posCubikRed.x = posCubikRed.x-50;
  1191. posPieceJOff1N1.x = posPieceJOff1N1.x-50;
  1192.  
  1193. posCubikRed.y = posCubikRed.y-50;
  1194. posPieceJOff1N1.y = posPieceJOff1N1.y-50;
  1195. }
  1196. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1197. {
  1198. posCubikRed.x = posCubikRed.x-50;
  1199. posPieceJOff1N1.x = posPieceJOff1N1.x-50;
  1200.  
  1201. posCubikRed.y = posCubikRed.y+50;
  1202. posPieceJOff1N1.y = posPieceJOff1N1.y+50;
  1203. }
  1204.  
  1205. /*posCubikRed.x = positionX-50;
  1206. posPieceJOff1N1.x = positionX-50;
  1207.  
  1208. posCubikRed.y = positionY-75;
  1209. posPieceJOff1N1.y = positionY-25;*/
  1210.  
  1211. //SDL_ShowCursor(SDL_DISABLE);
  1212.  
  1213. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1214. switch(event.type) /* On teste le type d'évènement */
  1215. {
  1216. case SDL_MOUSEBUTTONUP:
  1217.  
  1218. for(j=0 ; j<=15 ; j++)
  1219. {
  1220. for (i=0 ; i<=15 ; i++)
  1221. {
  1222. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1223. {
  1224. posPieceJOff1N1.x = PosCasesJ1off[i][j].x;
  1225. posPieceJOff1N1.y = PosCasesJ1off[i][j].y;
  1226. }
  1227. }
  1228. }
  1229.  
  1230. //SDL_ShowCursor(SDL_ENABLE);
  1231. dragAndDrop = 0;
  1232. break;
  1233. }
  1234.  
  1235. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1236. if(compteurFond == 0)
  1237. {
  1238. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1239. }
  1240. else if(compteurFond == 1)
  1241. {
  1242. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1243. }
  1244. else if(compteurFond == 2)
  1245. {
  1246. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1247. }
  1248. else if(compteurFond == 3)
  1249. {
  1250. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1251. }
  1252. else
  1253. {
  1254. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1255. }
  1256.  
  1257. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1258. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1259. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1260. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1261. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1262. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1263. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1264. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1265. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1266. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1267. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1268. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1269. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1270. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1271. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1272. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1273. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1274. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1275. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1276. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1277. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1278. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1279. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1280. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1281. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1282. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1283. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1284. }
  1285. }
  1286.  
  1287. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a2][b2].x && event.motion.x <= PointBas[a2][b2].x && event.motion.y >= PointMid[a2][b2].y && event.motion.y <= PointBas[a2][b2].y)
  1288. {
  1289. while (dragAndDrop)
  1290. {
  1291. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1292. posPieceX = posPieceJOff1N2.x;
  1293. posCubikRed.x = posPieceX;
  1294. posCubeX = posCubikRed.x;
  1295.  
  1296.  
  1297. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1298. posPieceY = posPieceJOff1N2.y;
  1299. posCubikRed.y = posPieceY-50;
  1300. posCubeY = posCubikRed.y;
  1301.  
  1302. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1303. {
  1304. posCubikRed.x = posCubikRed.x+50;
  1305. posPieceJOff1N2.x = posPieceJOff1N2.x+50;
  1306.  
  1307. posCubikRed.y = posCubikRed.y+50;
  1308. posPieceJOff1N2.y = posPieceJOff1N2.y+50;
  1309. }
  1310. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1311. {
  1312. posCubikRed.x = posCubikRed.x+50;
  1313. posPieceJOff1N2.x = posPieceJOff1N2.x+50;
  1314.  
  1315. posCubikRed.y = posCubikRed.y-50;
  1316. posPieceJOff1N2.y = posPieceJOff1N2.y-50;
  1317. }
  1318.  
  1319. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1320. {
  1321. posCubikRed.x = posCubikRed.x-50;
  1322. posPieceJOff1N2.x = posPieceJOff1N2.x-50;
  1323.  
  1324. posCubikRed.y = posCubikRed.y-50;
  1325. posPieceJOff1N2.y = posPieceJOff1N2.y-50;
  1326. }
  1327. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1328. {
  1329. posCubikRed.x = posCubikRed.x-50;
  1330. posPieceJOff1N2.x = posPieceJOff1N2.x-50;
  1331.  
  1332. posCubikRed.y = posCubikRed.y+50;
  1333. posPieceJOff1N2.y = posPieceJOff1N2.y+50;
  1334. }
  1335.  
  1336. SDL_ShowCursor(SDL_DISABLE);
  1337.  
  1338. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1339. switch(event.type) /* On teste le type d'évènement */
  1340. {
  1341. case SDL_MOUSEBUTTONUP:
  1342.  
  1343. for(j=0 ; j<=15 ; j++)
  1344. {
  1345. for (i=0 ; i<=15 ; i++)
  1346. {
  1347. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1348. {
  1349. posPieceJOff1N2.x = PosCasesJ1off[i][j].x;
  1350. posPieceJOff1N2.y = PosCasesJ1off[i][j].y;
  1351. }
  1352. }
  1353. }
  1354.  
  1355. SDL_ShowCursor(SDL_ENABLE);
  1356. dragAndDrop = 0;
  1357. break;
  1358. }
  1359.  
  1360. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1361. if(compteurFond == 0)
  1362. {
  1363. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1364. }
  1365. else if(compteurFond == 1)
  1366. {
  1367. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1368. }
  1369. else if(compteurFond == 2)
  1370. {
  1371. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1372. }
  1373. else if(compteurFond == 3)
  1374. {
  1375. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1376. }
  1377. else
  1378. {
  1379. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1380. }
  1381.  
  1382. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1383. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1384. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1385. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1386. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1387. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1388. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1389. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1390. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1391. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1392. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1393. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1394. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1395. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1396. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1397. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1398. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1399. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1400. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1401. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1402. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1403. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1404. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1405. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1406. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1407. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1408. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1409. }
  1410. }
  1411.  
  1412. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a3][b3].x && event.motion.x <= PointBas[a3][b3].x && event.motion.y >= PointMid[a3][b3].y && event.motion.y <= PointBas[a3][b3].y)
  1413. {
  1414. while (dragAndDrop)
  1415. {
  1416. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1417. posPieceX = posPieceJOff1N3.x;
  1418. posCubikRed.x = posPieceX;
  1419. posCubeX = posCubikRed.x;
  1420.  
  1421.  
  1422. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1423. posPieceY = posPieceJOff1N3.y;
  1424. posCubikRed.y = posPieceY-50;
  1425. posCubeY = posCubikRed.y;
  1426.  
  1427. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1428. {
  1429. posCubikRed.x = posCubikRed.x+50;
  1430. posPieceJOff1N3.x = posPieceJOff1N3.x+50;
  1431.  
  1432. posCubikRed.y = posCubikRed.y+50;
  1433. posPieceJOff1N3.y = posPieceJOff1N3.y+50;
  1434. }
  1435. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1436. {
  1437. posCubikRed.x = posCubikRed.x+50;
  1438. posPieceJOff1N3.x = posPieceJOff1N3.x+50;
  1439.  
  1440. posCubikRed.y = posCubikRed.y-50;
  1441. posPieceJOff1N3.y = posPieceJOff1N3.y-50;
  1442. }
  1443.  
  1444. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1445. {
  1446. posCubikRed.x = posCubikRed.x-50;
  1447. posPieceJOff1N3.x = posPieceJOff1N3.x-50;
  1448.  
  1449. posCubikRed.y = posCubikRed.y-50;
  1450. posPieceJOff1N3.y = posPieceJOff1N3.y-50;
  1451. }
  1452. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1453. {
  1454. posCubikRed.x = posCubikRed.x-50;
  1455. posPieceJOff1N3.x = posPieceJOff1N3.x-50;
  1456.  
  1457. posCubikRed.y = posCubikRed.y+50;
  1458. posPieceJOff1N3.y = posPieceJOff1N3.y+50;
  1459. }
  1460.  
  1461. SDL_ShowCursor(SDL_DISABLE);
  1462.  
  1463. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1464. switch(event.type) /* On teste le type d'évènement */
  1465. {
  1466. case SDL_MOUSEBUTTONUP:
  1467.  
  1468. for(j=0 ; j<=15 ; j++)
  1469. {
  1470. for (i=0 ; i<=15 ; i++)
  1471. {
  1472. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1473. {
  1474. posPieceJOff1N3.x = PosCasesJ1off[i][j].x;
  1475. posPieceJOff1N3.y = PosCasesJ1off[i][j].y;
  1476. }
  1477. }
  1478. }
  1479.  
  1480. SDL_ShowCursor(SDL_ENABLE);
  1481. dragAndDrop = 0;
  1482. break;
  1483. }
  1484.  
  1485. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1486. if(compteurFond == 0)
  1487. {
  1488. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1489. }
  1490. else if(compteurFond == 1)
  1491. {
  1492. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1493. }
  1494. else if(compteurFond == 2)
  1495. {
  1496. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1497. }
  1498. else if(compteurFond == 3)
  1499. {
  1500. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1501. }
  1502. else
  1503. {
  1504. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1505. }
  1506.  
  1507. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1508. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1509. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1510. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1511. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1512. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1513. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1514. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1515. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1516. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1517. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1518. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1519. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1520. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1521. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1522. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1523. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1524. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1525. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1526. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1527. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1528. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1529. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1530. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1531. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1532. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1533. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1534. }
  1535. }
  1536.  
  1537. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a4][b4].x && event.motion.x <= PointBas[a4][b4].x && event.motion.y >= PointMid[a4][b4].y && event.motion.y <= PointBas[a4][b4].y)
  1538. {
  1539. while (dragAndDrop)
  1540. {
  1541. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1542. posPieceX = posPieceJOff1N4.x;
  1543. posCubikRed.x = posPieceX;
  1544. posCubeX = posCubikRed.x;
  1545.  
  1546.  
  1547. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1548. posPieceY = posPieceJOff1N4.y;
  1549. posCubikRed.y = posPieceY-50;
  1550. posCubeY = posCubikRed.y;
  1551.  
  1552. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1553. {
  1554. posCubikRed.x = posCubikRed.x+50;
  1555. posPieceJOff1N4.x = posPieceJOff1N4.x+50;
  1556.  
  1557. posCubikRed.y = posCubikRed.y+50;
  1558. posPieceJOff1N4.y = posPieceJOff1N4.y+50;
  1559. }
  1560. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1561. {
  1562. posCubikRed.x = posCubikRed.x+50;
  1563. posPieceJOff1N4.x = posPieceJOff1N4.x+50;
  1564.  
  1565. posCubikRed.y = posCubikRed.y-50;
  1566. posPieceJOff1N4.y = posPieceJOff1N4.y-50;
  1567. }
  1568.  
  1569. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1570. {
  1571. posCubikRed.x = posCubikRed.x-50;
  1572. posPieceJOff1N4.x = posPieceJOff1N4.x-50;
  1573.  
  1574. posCubikRed.y = posCubikRed.y-50;
  1575. posPieceJOff1N4.y = posPieceJOff1N4.y-50;
  1576. }
  1577. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1578. {
  1579. posCubikRed.x = posCubikRed.x-50;
  1580. posPieceJOff1N4.x = posPieceJOff1N4.x-50;
  1581.  
  1582. posCubikRed.y = posCubikRed.y+50;
  1583. posPieceJOff1N4.y = posPieceJOff1N4.y+50;
  1584. }
  1585.  
  1586. SDL_ShowCursor(SDL_DISABLE);
  1587.  
  1588. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1589. switch(event.type) /* On teste le type d'évènement */
  1590. {
  1591. case SDL_MOUSEBUTTONUP:
  1592.  
  1593. for(j=0 ; j<=15 ; j++)
  1594. {
  1595. for (i=0 ; i<=15 ; i++)
  1596. {
  1597. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1598. {
  1599. posPieceJOff1N4.x = PosCasesJ1off[i][j].x;
  1600. posPieceJOff1N4.y = PosCasesJ1off[i][j].y;
  1601. }
  1602. }
  1603. }
  1604.  
  1605. SDL_ShowCursor(SDL_ENABLE);
  1606. dragAndDrop = 0;
  1607. break;
  1608. }
  1609.  
  1610. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1611. if(compteurFond == 0)
  1612. {
  1613. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1614. }
  1615. else if(compteurFond == 1)
  1616. {
  1617. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1618. }
  1619. else if(compteurFond == 2)
  1620. {
  1621. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1622. }
  1623. else if(compteurFond == 3)
  1624. {
  1625. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1626. }
  1627. else
  1628. {
  1629. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1630. }
  1631.  
  1632. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1633. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1634. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1635. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1636. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1637. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1638. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1639. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1640. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1641. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1642. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1643. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1644. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1645. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1646. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1647. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1648. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1649. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1650. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1651. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1652. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1653. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1654. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1655. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1656. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1657. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1658. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1659. }
  1660. }
  1661.  
  1662. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a5][b5].x && event.motion.x <= PointBas[a5][b5].x && event.motion.y >= PointMid[a5][b5].y && event.motion.y <= PointBas[a5][b5].y)
  1663. {
  1664. while (dragAndDrop)
  1665. {
  1666. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1667. posPieceX = posPieceJOff1N5.x;
  1668. posCubikRed.x = posPieceX;
  1669. posCubeX = posCubikRed.x;
  1670.  
  1671.  
  1672. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1673. posPieceY = posPieceJOff1N5.y;
  1674. posCubikRed.y = posPieceY-50;
  1675. posCubeY = posCubikRed.y;
  1676.  
  1677. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1678. {
  1679. posCubikRed.x = posCubikRed.x+50;
  1680. posPieceJOff1N5.x = posPieceJOff1N5.x+50;
  1681.  
  1682. posCubikRed.y = posCubikRed.y+50;
  1683. posPieceJOff1N5.y = posPieceJOff1N5.y+50;
  1684. }
  1685. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1686. {
  1687. posCubikRed.x = posCubikRed.x+50;
  1688. posPieceJOff1N5.x = posPieceJOff1N5.x+50;
  1689.  
  1690. posCubikRed.y = posCubikRed.y-50;
  1691. posPieceJOff1N5.y = posPieceJOff1N5.y-50;
  1692. }
  1693.  
  1694. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1695. {
  1696. posCubikRed.x = posCubikRed.x-50;
  1697. posPieceJOff1N5.x = posPieceJOff1N5.x-50;
  1698.  
  1699. posCubikRed.y = posCubikRed.y-50;
  1700. posPieceJOff1N5.y = posPieceJOff1N5.y-50;
  1701. }
  1702. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1703. {
  1704. posCubikRed.x = posCubikRed.x-50;
  1705. posPieceJOff1N5.x = posPieceJOff1N5.x-50;
  1706.  
  1707. posCubikRed.y = posCubikRed.y+50;
  1708. posPieceJOff1N5.y = posPieceJOff1N5.y+50;
  1709. }
  1710.  
  1711.  
  1712. SDL_ShowCursor(SDL_DISABLE);
  1713.  
  1714. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1715. switch(event.type) /* On teste le type d'évènement */
  1716. {
  1717. case SDL_MOUSEBUTTONUP:
  1718.  
  1719. for(j=0 ; j<=15 ; j++)
  1720. {
  1721. for (i=0 ; i<=15 ; i++)
  1722. {
  1723. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1724. {
  1725. posPieceJOff1N5.x = PosCasesJ1off[i][j].x;
  1726. posPieceJOff1N5.y = PosCasesJ1off[i][j].y;
  1727. }
  1728. }
  1729. }
  1730.  
  1731. SDL_ShowCursor(SDL_ENABLE);
  1732. dragAndDrop = 0;
  1733. break;
  1734. }
  1735.  
  1736. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1737. if(compteurFond == 0)
  1738. {
  1739. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1740. }
  1741. else if(compteurFond == 1)
  1742. {
  1743. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1744. }
  1745. else if(compteurFond == 2)
  1746. {
  1747. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1748. }
  1749. else if(compteurFond == 3)
  1750. {
  1751. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1752. }
  1753. else
  1754. {
  1755. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1756. }
  1757.  
  1758. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1759. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1760. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1761. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1762. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1763. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1764. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1765. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1766. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1767. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1768. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1769. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1770. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1771. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1772. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1773. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1774. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1775. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1776. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1777. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1778. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1779. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1780. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1781. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1782. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1783. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1784. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1785. }
  1786. }
  1787.  
  1788. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[a6][b6].x && event.motion.x <= PointBas[a6][b6].x && event.motion.y >= PointMid[a6][b6].y && event.motion.y <= PointBas[a6][b6].y)
  1789. {
  1790. while (dragAndDrop)
  1791. {
  1792. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1793. posPieceX = posPieceJOff1N6.x;
  1794. posCubikRed.x = posPieceX;
  1795. posCubeX = posCubikRed.x;
  1796.  
  1797.  
  1798. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1799. posPieceY = posPieceJOff1N6.y;
  1800. posCubikRed.y = posPieceY-50;
  1801. posCubeY = posCubikRed.y;
  1802.  
  1803. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1804. {
  1805. posCubikRed.x = posCubikRed.x+50;
  1806. posPieceJOff1N6.x = posPieceJOff1N6.x+50;
  1807.  
  1808. posCubikRed.y = posCubikRed.y+50;
  1809. posPieceJOff1N6.y = posPieceJOff1N6.y+50;
  1810. }
  1811. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1812. {
  1813. posCubikRed.x = posCubikRed.x+50;
  1814. posPieceJOff1N6.x = posPieceJOff1N6.x+50;
  1815.  
  1816. posCubikRed.y = posCubikRed.y-50;
  1817. posPieceJOff1N6.y = posPieceJOff1N6.y-50;
  1818. }
  1819.  
  1820. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1821. {
  1822. posCubikRed.x = posCubikRed.x-50;
  1823. posPieceJOff1N6.x = posPieceJOff1N6.x-50;
  1824.  
  1825. posCubikRed.y = posCubikRed.y-50;
  1826. posPieceJOff1N6.y = posPieceJOff1N6.y-50;
  1827. }
  1828. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1829. {
  1830. posCubikRed.x = posCubikRed.x-50;
  1831. posPieceJOff1N6.x = posPieceJOff1N6.x-50;
  1832.  
  1833. posCubikRed.y = posCubikRed.y+50;
  1834. posPieceJOff1N6.y = posPieceJOff1N6.y+50;
  1835. }
  1836.  
  1837. SDL_ShowCursor(SDL_DISABLE);
  1838.  
  1839. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1840. switch(event.type) /* On teste le type d'évènement */
  1841. {
  1842. case SDL_MOUSEBUTTONUP:
  1843.  
  1844. for(j=0 ; j<=15 ; j++)
  1845. {
  1846. for (i=0 ; i<=15 ; i++)
  1847. {
  1848. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1849. {
  1850. posPieceJOff1N6.x = PosCasesJ1off[i][j].x;
  1851. posPieceJOff1N6.y = PosCasesJ1off[i][j].y;
  1852. }
  1853. }
  1854. }
  1855.  
  1856. SDL_ShowCursor(SDL_ENABLE);
  1857. dragAndDrop = 0;
  1858. break;
  1859. }
  1860.  
  1861. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1862. if(compteurFond == 0)
  1863. {
  1864. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1865. }
  1866. else if(compteurFond == 1)
  1867. {
  1868. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1869. }
  1870. else if(compteurFond == 2)
  1871. {
  1872. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1873. }
  1874. else if(compteurFond == 3)
  1875. {
  1876. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  1877. }
  1878. else
  1879. {
  1880. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  1881. }
  1882.  
  1883. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  1884. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  1885. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  1886. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  1887. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  1888. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  1889. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  1890. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  1891. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  1892. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  1893. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  1894. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  1895. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  1896. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  1897. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  1898. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  1899. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  1900. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  1901. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  1902. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  1903. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  1904. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  1905. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  1906. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  1907. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  1908. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  1909. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  1910. }
  1911. }
  1912.  
  1913. //on passe au pieces defensive du joueur1
  1914. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c1][d1].x && event.motion.x <= PointBas[c1][d1].x && event.motion.y >= PointMid[c1][d1].y && event.motion.y <= PointBas[c1][d1].y)
  1915. {
  1916. while (dragAndDrop)
  1917. {
  1918. positionX = event.motion.x; /* On change les coordonnées de la piece */
  1919. posPieceX = posPieceJDef1N1.x;
  1920. posCubikRed.x = posPieceX;
  1921. posCubeX = posCubikRed.x;
  1922.  
  1923.  
  1924. positionY = event.motion.y; /* On change les coordonnées de la piece */
  1925. posPieceY = posPieceJDef1N1.y;
  1926. posCubikRed.y = posPieceY-45;
  1927. posCubeY = posCubikRed.y;
  1928.  
  1929. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  1930. {
  1931. posCubikRed.x = posCubikRed.x+50;
  1932. posPieceJDef1N1.x = posPieceJDef1N1.x+50;
  1933.  
  1934. posCubikRed.y = posCubikRed.y+50;
  1935. posPieceJDef1N1.y = posPieceJDef1N1.y+50;
  1936. }
  1937. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  1938. {
  1939. posCubikRed.x = posCubikRed.x+50;
  1940. posPieceJDef1N1.x = posPieceJDef1N1.x+50;
  1941.  
  1942. posCubikRed.y = posCubikRed.y-50;
  1943. posPieceJDef1N1.y = posPieceJDef1N1.y-50;
  1944. }
  1945.  
  1946. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  1947. {
  1948. posCubikRed.x = posCubikRed.x-50;
  1949. posPieceJDef1N1.x = posPieceJDef1N1.x-50;
  1950.  
  1951. posCubikRed.y = posCubikRed.y-50;
  1952. posPieceJDef1N1.y = posPieceJDef1N1.y-50;
  1953. }
  1954. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  1955. {
  1956. posCubikRed.x = posCubikRed.x-50;
  1957. posPieceJDef1N1.x = posPieceJDef1N1.x-50;
  1958.  
  1959. posCubikRed.y = posCubikRed.y+50;
  1960. posPieceJDef1N1.y = posPieceJDef1N1.y+50;
  1961. }
  1962.  
  1963. SDL_ShowCursor(SDL_DISABLE);
  1964.  
  1965. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  1966. switch(event.type) /* On teste le type d'évènement */
  1967. {
  1968. case SDL_MOUSEBUTTONUP:
  1969.  
  1970. for(j=0 ; j<=15 ; j++)
  1971. {
  1972. for (i=0 ; i<=15 ; i++)
  1973. {
  1974. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  1975. {
  1976. posPieceJDef1N1.x = PosCasesJ1def[i][j].x;
  1977. posPieceJDef1N1.y = PosCasesJ1def[i][j].y;
  1978. }
  1979. }
  1980. }
  1981.  
  1982. SDL_ShowCursor(SDL_ENABLE);
  1983. dragAndDrop = 0;
  1984. break;
  1985. }
  1986.  
  1987. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  1988. if(compteurFond == 0)
  1989. {
  1990. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  1991. }
  1992. else if(compteurFond == 1)
  1993. {
  1994. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  1995. }
  1996. else if(compteurFond == 2)
  1997. {
  1998. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  1999. }
  2000. else if(compteurFond == 3)
  2001. {
  2002. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2003. }
  2004. else
  2005. {
  2006. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2007. }
  2008.  
  2009. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2010. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2011. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2012. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2013. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2014. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2015. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2016. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2017. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2018. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2019. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2020. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2021. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2022. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2023. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2024. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2025. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2026. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2027. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2028. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2029. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2030. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2031. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2032. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2033. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2034. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2035. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2036. }
  2037. }
  2038.  
  2039. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c2][d2].x && event.motion.x <= PointBas[c2][d2].x && event.motion.y >= PointMid[c2][d2].y && event.motion.y <= PointBas[c2][d2].y)
  2040. {
  2041. while (dragAndDrop)
  2042. {
  2043. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2044. posPieceX = posPieceJDef1N2.x;
  2045. posCubikRed.x = posPieceX;
  2046. posCubeX = posCubikRed.x;
  2047.  
  2048.  
  2049. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2050. posPieceY = posPieceJDef1N2.y;
  2051. posCubikRed.y = posPieceY-45;
  2052. posCubeY = posCubikRed.y;
  2053.  
  2054. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2055. {
  2056. posCubikRed.x = posCubikRed.x+50;
  2057. posPieceJDef1N2.x = posPieceJDef1N2.x+50;
  2058.  
  2059. posCubikRed.y = posCubikRed.y+50;
  2060. posPieceJDef1N2.y = posPieceJDef1N2.y+50;
  2061. }
  2062. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2063. {
  2064. posCubikRed.x = posCubikRed.x+50;
  2065. posPieceJDef1N2.x = posPieceJDef1N2.x+50;
  2066.  
  2067. posCubikRed.y = posCubikRed.y-50;
  2068. posPieceJDef1N2.y = posPieceJDef1N2.y-50;
  2069. }
  2070.  
  2071. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2072. {
  2073. posCubikRed.x = posCubikRed.x-50;
  2074. posPieceJDef1N2.x = posPieceJDef1N2.x-50;
  2075.  
  2076. posCubikRed.y = posCubikRed.y-50;
  2077. posPieceJDef1N2.y = posPieceJDef1N2.y-50;
  2078. }
  2079. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2080. {
  2081. posCubikRed.x = posCubikRed.x-50;
  2082. posPieceJDef1N2.x = posPieceJDef1N2.x-50;
  2083.  
  2084. posCubikRed.y = posCubikRed.y+50;
  2085. posPieceJDef1N2.y = posPieceJDef1N2.y+50;
  2086. }
  2087.  
  2088. SDL_ShowCursor(SDL_DISABLE);
  2089.  
  2090. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2091. switch(event.type) /* On teste le type d'évènement */
  2092. {
  2093. case SDL_MOUSEBUTTONUP:
  2094.  
  2095. for(j=0 ; j<=15 ; j++)
  2096. {
  2097. for (i=0 ; i<=15 ; i++)
  2098. {
  2099. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  2100. {
  2101. posPieceJDef1N2.x = PosCasesJ1def[i][j].x;
  2102. posPieceJDef1N2.y = PosCasesJ1def[i][j].y;
  2103. }
  2104. }
  2105. }
  2106.  
  2107. SDL_ShowCursor(SDL_ENABLE);
  2108. dragAndDrop = 0;
  2109. break;
  2110. }
  2111.  
  2112. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2113. if(compteurFond == 0)
  2114. {
  2115. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2116. }
  2117. else if(compteurFond == 1)
  2118. {
  2119. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2120. }
  2121. else if(compteurFond == 2)
  2122. {
  2123. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2124. }
  2125. else if(compteurFond == 3)
  2126. {
  2127. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2128. }
  2129. else
  2130. {
  2131. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2132. }
  2133.  
  2134. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2135. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2136. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2137. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2138. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2139. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2140. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2141. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2142. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2143. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2144. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2145. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2146. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2147. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2148. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2149. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2150. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2151. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2152. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2153. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2154. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2155. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2156. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2157. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2158. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2159. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2160. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2161. }
  2162. }
  2163. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c3][d3].x && event.motion.x <= PointBas[c3][d3].x && event.motion.y >= PointMid[c3][d3].y && event.motion.y <= PointBas[c3][d3].y)
  2164. {
  2165. while (dragAndDrop)
  2166. {
  2167. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2168. posPieceX = posPieceJDef1N3.x;
  2169. posCubikRed.x = posPieceX;
  2170. posCubeX = posCubikRed.x;
  2171.  
  2172.  
  2173. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2174. posPieceY = posPieceJDef1N3.y;
  2175. posCubikRed.y = posPieceY-45;
  2176. posCubeY = posCubikRed.y;
  2177.  
  2178. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2179. {
  2180. posCubikRed.x = posCubikRed.x+50;
  2181. posPieceJDef1N3.x = posPieceJDef1N3.x+50;
  2182.  
  2183. posCubikRed.y = posCubikRed.y+50;
  2184. posPieceJDef1N3.y = posPieceJDef1N3.y+50;
  2185. }
  2186. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2187. {
  2188. posCubikRed.x = posCubikRed.x+50;
  2189. posPieceJDef1N3.x = posPieceJDef1N3.x+50;
  2190.  
  2191. posCubikRed.y = posCubikRed.y-50;
  2192. posPieceJDef1N3.y = posPieceJDef1N3.y-50;
  2193. }
  2194.  
  2195. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2196. {
  2197. posCubikRed.x = posCubikRed.x-50;
  2198. posPieceJDef1N3.x = posPieceJDef1N3.x-50;
  2199.  
  2200. posCubikRed.y = posCubikRed.y-50;
  2201. posPieceJDef1N3.y = posPieceJDef1N3.y-50;
  2202. }
  2203. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2204. {
  2205. posCubikRed.x = posCubikRed.x-50;
  2206. posPieceJDef1N3.x = posPieceJDef1N3.x-50;
  2207.  
  2208. posCubikRed.y = posCubikRed.y+50;
  2209. posPieceJDef1N3.y = posPieceJDef1N3.y+50;
  2210. }
  2211.  
  2212. SDL_ShowCursor(SDL_DISABLE);
  2213.  
  2214. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2215. switch(event.type) /* On teste le type d'évènement */
  2216. {
  2217. case SDL_MOUSEBUTTONUP:
  2218.  
  2219. for(j=0 ; j<=15 ; j++)
  2220. {
  2221. for (i=0 ; i<=15 ; i++)
  2222. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  2223. {
  2224. {
  2225. posPieceJDef1N3.x = PosCasesJ1def[i][j].x;
  2226. posPieceJDef1N3.y = PosCasesJ1def[i][j].y;
  2227. }
  2228. }
  2229. }
  2230.  
  2231. SDL_ShowCursor(SDL_ENABLE);
  2232. dragAndDrop = 0;
  2233. break;
  2234. }
  2235.  
  2236. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2237. if(compteurFond == 0)
  2238. {
  2239. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2240. }
  2241. else if(compteurFond == 1)
  2242. {
  2243. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2244. }
  2245. else if(compteurFond == 2)
  2246. {
  2247. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2248. }
  2249. else if(compteurFond == 3)
  2250. {
  2251. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2252. }
  2253. else
  2254. {
  2255. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2256. }
  2257.  
  2258. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2259. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2260. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2261. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2262. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2263. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2264. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2265. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2266. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2267. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2268. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2269. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2270. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2271. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2272. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2273. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2274. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2275. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2276. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2277. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2278. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2279. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2280. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2281. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2282. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2283. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2284. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2285. }
  2286. }
  2287. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c4][d4].x && event.motion.x <= PointBas[c4][d4].x && event.motion.y >= PointMid[c4][d4].y && event.motion.y <= PointBas[c4][d4].y)
  2288. {
  2289. while (dragAndDrop)
  2290. {
  2291. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2292. posPieceX = posPieceJDef1N4.x;
  2293. posCubikRed.x = posPieceX;
  2294. posCubeX = posCubikRed.x;
  2295.  
  2296.  
  2297. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2298. posPieceY = posPieceJDef1N4.y;
  2299. posCubikRed.y = posPieceY-45;
  2300. posCubeY = posCubikRed.y;
  2301.  
  2302. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2303. {
  2304. posCubikRed.x = posCubikRed.x+50;
  2305. posPieceJDef1N4.x = posPieceJDef1N4.x+50;
  2306.  
  2307. posCubikRed.y = posCubikRed.y+50;
  2308. posPieceJDef1N4.y = posPieceJDef1N4.y+50;
  2309. }
  2310. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2311. {
  2312. posCubikRed.x = posCubikRed.x+50;
  2313. posPieceJDef1N4.x = posPieceJDef1N4.x+50;
  2314.  
  2315. posCubikRed.y = posCubikRed.y-50;
  2316. posPieceJDef1N4.y = posPieceJDef1N4.y-50;
  2317. }
  2318.  
  2319. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2320. {
  2321. posCubikRed.x = posCubikRed.x-50;
  2322. posPieceJDef1N4.x = posPieceJDef1N4.x-50;
  2323.  
  2324. posCubikRed.y = posCubikRed.y-50;
  2325. posPieceJDef1N4.y = posPieceJDef1N4.y-50;
  2326. }
  2327. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2328. {
  2329. posCubikRed.x = posCubikRed.x-50;
  2330. posPieceJDef1N4.x = posPieceJDef1N4.x-50;
  2331.  
  2332. posCubikRed.y = posCubikRed.y+50;
  2333. posPieceJDef1N4.y = posPieceJDef1N4.y+50;
  2334. }
  2335.  
  2336. SDL_ShowCursor(SDL_DISABLE);
  2337.  
  2338. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2339. switch(event.type) /* On teste le type d'évènement */
  2340. {
  2341. case SDL_MOUSEBUTTONUP:
  2342.  
  2343. for(j=0 ; j<=15 ; j++)
  2344. {
  2345. for (i=0 ; i<=15 ; i++)
  2346. {
  2347. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  2348. {
  2349. posPieceJDef1N4.x = PosCasesJ1def[i][j].x;
  2350. posPieceJDef1N4.y = PosCasesJ1def[i][j].y;
  2351. }
  2352. }
  2353. }
  2354.  
  2355. SDL_ShowCursor(SDL_ENABLE);
  2356. dragAndDrop = 0;
  2357. break;
  2358. }
  2359.  
  2360. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2361. if(compteurFond == 0)
  2362. {
  2363. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2364. }
  2365. else if(compteurFond == 1)
  2366. {
  2367. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2368. }
  2369. else if(compteurFond == 2)
  2370. {
  2371. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2372. }
  2373. else if(compteurFond == 3)
  2374. {
  2375. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2376. }
  2377. else
  2378. {
  2379. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2380. }
  2381.  
  2382. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2383. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2384. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2385. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2386. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2387. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2388. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2389. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2390. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2391. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2392. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2393. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2394. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2395. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2396. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2397. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2398. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2399. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2400. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2401. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2402. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2403. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2404. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2405. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2406. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2407. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2408. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2409. }
  2410. }
  2411. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c5][d5].x && event.motion.x <= PointBas[c5][d5].x && event.motion.y >= PointMid[c5][d5].y && event.motion.y <= PointBas[c5][d5].y)
  2412. {
  2413. while (dragAndDrop)
  2414. {
  2415. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2416. posPieceX = posPieceJDef1N5.x;
  2417. posCubikRed.x = posPieceX;
  2418. posCubeX = posCubikRed.x;
  2419.  
  2420.  
  2421. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2422. posPieceY = posPieceJDef1N5.y;
  2423. posCubikRed.y = posPieceY-45;
  2424. posCubeY = posCubikRed.y;
  2425.  
  2426. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2427. {
  2428. posCubikRed.x = posCubikRed.x+50;
  2429. posPieceJDef1N5.x = posPieceJDef1N5.x+50;
  2430.  
  2431. posCubikRed.y = posCubikRed.y+50;
  2432. posPieceJDef1N5.y = posPieceJDef1N5.y+50;
  2433. }
  2434. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2435. {
  2436. posCubikRed.x = posCubikRed.x+50;
  2437. posPieceJDef1N5.x = posPieceJDef1N5.x+50;
  2438.  
  2439. posCubikRed.y = posCubikRed.y-50;
  2440. posPieceJDef1N5.y = posPieceJDef1N5.y-50;
  2441. }
  2442.  
  2443. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2444. {
  2445. posCubikRed.x = posCubikRed.x-50;
  2446. posPieceJDef1N5.x = posPieceJDef1N5.x-50;
  2447.  
  2448. posCubikRed.y = posCubikRed.y-50;
  2449. posPieceJDef1N5.y = posPieceJDef1N5.y-50;
  2450. }
  2451. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2452. {
  2453. posCubikRed.x = posCubikRed.x-50;
  2454. posPieceJDef1N5.x = posPieceJDef1N5.x-50;
  2455.  
  2456. posCubikRed.y = posCubikRed.y+50;
  2457. posPieceJDef1N5.y = posPieceJDef1N5.y+50;
  2458. }
  2459.  
  2460. SDL_ShowCursor(SDL_DISABLE);
  2461.  
  2462. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2463. switch(event.type) /* On teste le type d'évènement */
  2464. {
  2465. case SDL_MOUSEBUTTONUP:
  2466.  
  2467. for(j=0 ; j<=15 ; j++)
  2468. {
  2469. for (i=0 ; i<=15 ; i++)
  2470. {
  2471. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  2472. {
  2473. posPieceJDef1N5.x = PosCasesJ1def[i][j].x;
  2474. posPieceJDef1N5.y = PosCasesJ1def[i][j].y;
  2475. }
  2476. }
  2477. }
  2478.  
  2479. SDL_ShowCursor(SDL_ENABLE);
  2480. dragAndDrop = 0;
  2481. break;
  2482. }
  2483.  
  2484. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2485. if(compteurFond == 0)
  2486. {
  2487. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2488. }
  2489. else if(compteurFond == 1)
  2490. {
  2491. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2492. }
  2493. else if(compteurFond == 2)
  2494. {
  2495. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2496. }
  2497. else if(compteurFond == 3)
  2498. {
  2499. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2500. }
  2501. else
  2502. {
  2503. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2504. }
  2505.  
  2506. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2507. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2508. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2509. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2510. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2511. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2512. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2513. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2514. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2515. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2516. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2517. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2518. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2519. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2520. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2521. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2522. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2523. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2524. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2525. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2526. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2527. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2528. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2529. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2530. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2531. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2532. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2533. }
  2534. }
  2535. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[c6][d6].x && event.motion.x <= PointBas[c6][d6].x && event.motion.y >= PointMid[c6][d6].y && event.motion.y <= PointBas[c6][d6].y)
  2536. {
  2537. while (dragAndDrop)
  2538. {
  2539. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2540. posPieceX = posPieceJDef1N6.x;
  2541. posCubikRed.x = posPieceX;
  2542. posCubeX = posCubikRed.x;
  2543.  
  2544.  
  2545. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2546. posPieceY = posPieceJDef1N6.y;
  2547. posCubikRed.y = posPieceY-45;
  2548. posCubeY = posCubikRed.y;
  2549.  
  2550. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2551. {
  2552. posCubikRed.x = posCubikRed.x+50;
  2553. posPieceJDef1N6.x = posPieceJDef1N6.x+50;
  2554.  
  2555. posCubikRed.y = posCubikRed.y+50;
  2556. posPieceJDef1N6.y = posPieceJDef1N6.y+50;
  2557. }
  2558. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2559. {
  2560. posCubikRed.x = posCubikRed.x+50;
  2561. posPieceJDef1N6.x = posPieceJDef1N6.x+50;
  2562.  
  2563. posCubikRed.y = posCubikRed.y-50;
  2564. posPieceJDef1N6.y = posPieceJDef1N6.y-50;
  2565. }
  2566.  
  2567. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2568. {
  2569. posCubikRed.x = posCubikRed.x-50;
  2570. posPieceJDef1N6.x = posPieceJDef1N6.x-50;
  2571.  
  2572. posCubikRed.y = posCubikRed.y-50;
  2573. posPieceJDef1N6.y = posPieceJDef1N6.y-50;
  2574. }
  2575. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2576. {
  2577. posCubikRed.x = posCubikRed.x-50;
  2578. posPieceJDef1N6.x = posPieceJDef1N6.x-50;
  2579.  
  2580. posCubikRed.y = posCubikRed.y+50;
  2581. posPieceJDef1N6.y = posPieceJDef1N6.y+50;
  2582. }
  2583.  
  2584. SDL_ShowCursor(SDL_DISABLE);
  2585.  
  2586. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2587. switch(event.type) /* On teste le type d'évènement */
  2588. {
  2589. case SDL_MOUSEBUTTONUP:
  2590.  
  2591. for(j=0 ; j<=15 ; j++)
  2592. {
  2593. for (i=0 ; i<=15 ; i++)
  2594. {
  2595. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointBas[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointBas[i][j].y)
  2596. {
  2597. posPieceJDef1N6.x = PosCasesJ1def[i][j].x;
  2598. posPieceJDef1N6.y = PosCasesJ1def[i][j].y;
  2599. }
  2600. }
  2601. }
  2602.  
  2603. SDL_ShowCursor(SDL_ENABLE);
  2604. dragAndDrop = 0;
  2605. break;
  2606. }
  2607.  
  2608. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2609. if(compteurFond == 0)
  2610. {
  2611. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2612. }
  2613. else if(compteurFond == 1)
  2614. {
  2615. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2616. }
  2617. else if(compteurFond == 2)
  2618. {
  2619. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2620. }
  2621. else if(compteurFond == 3)
  2622. {
  2623. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2624. }
  2625. else
  2626. {
  2627. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2628. }
  2629.  
  2630. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2631. SDL_BlitSurface(CubikRed, NULL, ecran, &posCubikRed);
  2632. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2633. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2634. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2635. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2636. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2637. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2638. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2639. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2640. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2641. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2642. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2643. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2644. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2645. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2646. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2647. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2648. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2649. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2650. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2651. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2652. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2653. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2654. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2655. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2656. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2657. }
  2658. }
  2659.  
  2660. //on passe au pièces du joueur2
  2661. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e1][f1].x && event.motion.x <= PointHaut[e1][f1].x && event.motion.y <= PointMid[e1][f1].y && event.motion.y >= PointHaut[e1][f1].y)
  2662. {
  2663. while (dragAndDrop)
  2664. {
  2665. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2666. posPieceX = posPieceJOff2N1.x;
  2667. posCubikBlue.x = posPieceX;
  2668. posCubeX = posCubikBlue.x;
  2669.  
  2670.  
  2671. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2672. posPieceY = posPieceJOff2N1.y;
  2673. posCubikBlue.y = posPieceY;
  2674. posCubeY = posCubikBlue.y;
  2675.  
  2676. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2677. {
  2678. posCubikBlue.x = posCubikBlue.x+50;
  2679. posPieceJOff2N1.x = posPieceJOff2N1.x+50;
  2680.  
  2681. posCubikBlue.y = posCubikBlue.y+50;
  2682. posPieceJOff2N1.y = posPieceJOff2N1.y+50;
  2683. }
  2684. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2685. {
  2686. posCubikBlue.x = posCubikBlue.x+50;
  2687. posPieceJOff2N1.x = posPieceJOff2N1.x+50;
  2688.  
  2689. posCubikBlue.y = posCubikBlue.y-50;
  2690. posPieceJOff2N1.y = posPieceJOff2N1.y-50;
  2691. }
  2692.  
  2693. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2694. {
  2695. posCubikBlue.x = posCubikBlue.x-50;
  2696. posPieceJOff2N1.x = posPieceJOff2N1.x-50;
  2697.  
  2698. posCubikBlue.y = posCubikBlue.y-50;
  2699. posPieceJOff2N1.y = posPieceJOff2N1.y-50;
  2700. }
  2701. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2702. {
  2703. posCubikBlue.x = posCubikBlue.x-50;
  2704. posPieceJOff2N1.x = posPieceJOff2N1.x-50;
  2705.  
  2706. posCubikBlue.y = posCubikBlue.y+50;
  2707. posPieceJOff2N1.y = posPieceJOff2N1.y+50;
  2708. }
  2709.  
  2710. SDL_ShowCursor(SDL_DISABLE);
  2711.  
  2712. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2713. switch(event.type) /* On teste le type d'évènement */
  2714. {
  2715. case SDL_MOUSEBUTTONUP:
  2716.  
  2717. for(j=0 ; j<=15 ; j++)
  2718. {
  2719. for (i=0 ; i<=15 ; i++)
  2720. {
  2721. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  2722. {
  2723. posPieceJOff2N1.x = PosCasesJ2[i][j].x;
  2724. posPieceJOff2N1.y = PosCasesJ2[i][j].y;
  2725. }
  2726. }
  2727. }
  2728.  
  2729. SDL_ShowCursor(SDL_ENABLE);
  2730. dragAndDrop = 0;
  2731. break;
  2732. }
  2733.  
  2734. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2735. if(compteurFond == 0)
  2736. {
  2737. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2738. }
  2739. else if(compteurFond == 1)
  2740. {
  2741. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2742. }
  2743. else if(compteurFond == 2)
  2744. {
  2745. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2746. }
  2747. else if(compteurFond == 3)
  2748. {
  2749. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2750. }
  2751. else
  2752. {
  2753. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2754. }
  2755.  
  2756. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2757. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  2758. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2759. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2760. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2761. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2762. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2763. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2764. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2765. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2766. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2767. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2768. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2769. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2770. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2771. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2772. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2773. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2774. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2775. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2776. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2777. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2778. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2779. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2780. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2781. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2782. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2783. }
  2784. }
  2785. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e2][f2].x && event.motion.x <= PointHaut[e2][f2].x && event.motion.y <= PointMid[e2][f2].y && event.motion.y >= PointHaut[e2][f2].y)
  2786. {
  2787. while (dragAndDrop)
  2788. {
  2789. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2790. posPieceX = posPieceJOff2N2.x;
  2791. posCubikBlue.x = posPieceX;
  2792. posCubeX = posCubikBlue.x;
  2793.  
  2794.  
  2795. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2796. posPieceY = posPieceJOff2N2.y;
  2797. posCubikBlue.y = posPieceY;
  2798. posCubeY = posCubikBlue.y;
  2799.  
  2800. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2801. {
  2802. posCubikBlue.x = posCubikBlue.x+50;
  2803. posPieceJOff2N2.x = posPieceJOff2N2.x+50;
  2804.  
  2805. posCubikBlue.y = posCubikBlue.y+50;
  2806. posPieceJOff2N2.y = posPieceJOff2N2.y+50;
  2807. }
  2808. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2809. {
  2810. posCubikBlue.x = posCubikBlue.x+50;
  2811. posPieceJOff2N2.x = posPieceJOff2N2.x+50;
  2812.  
  2813. posCubikBlue.y = posCubikBlue.y-50;
  2814. posPieceJOff2N2.y = posPieceJOff2N2.y-50;
  2815. }
  2816.  
  2817. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2818. {
  2819. posCubikBlue.x = posCubikBlue.x-50;
  2820. posPieceJOff2N2.x = posPieceJOff2N2.x-50;
  2821.  
  2822. posCubikBlue.y = posCubikBlue.y-50;
  2823. posPieceJOff2N2.y = posPieceJOff2N2.y-50;
  2824. }
  2825. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2826. {
  2827. posCubikBlue.x = posCubikBlue.x-50;
  2828. posPieceJOff2N2.x = posPieceJOff2N2.x-50;
  2829.  
  2830. posCubikBlue.y = posCubikBlue.y+50;
  2831. posPieceJOff2N2.y = posPieceJOff2N2.y+50;
  2832. }
  2833.  
  2834. SDL_ShowCursor(SDL_DISABLE);
  2835.  
  2836. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2837. switch(event.type) /* On teste le type d'évènement */
  2838. {
  2839. case SDL_MOUSEBUTTONUP:
  2840.  
  2841. for(j=0 ; j<=15 ; j++)
  2842. {
  2843. for (i=0 ; i<=15 ; i++)
  2844. {
  2845. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  2846. {
  2847. posPieceJOff2N2.x = PosCasesJ2[i][j].x;
  2848. posPieceJOff2N2.y = PosCasesJ2[i][j].y;
  2849. }
  2850. }
  2851. }
  2852.  
  2853. SDL_ShowCursor(SDL_ENABLE);
  2854. dragAndDrop = 0;
  2855. break;
  2856. }
  2857.  
  2858. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2859. if(compteurFond == 0)
  2860. {
  2861. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2862. }
  2863. else if(compteurFond == 1)
  2864. {
  2865. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2866. }
  2867. else if(compteurFond == 2)
  2868. {
  2869. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2870. }
  2871. else if(compteurFond == 3)
  2872. {
  2873. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2874. }
  2875. else
  2876. {
  2877. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  2878. }
  2879.  
  2880. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  2881. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  2882. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  2883. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  2884. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  2885. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  2886. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  2887. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  2888. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  2889. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  2890. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  2891. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  2892. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  2893. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  2894. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  2895. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  2896. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  2897. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  2898. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  2899. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  2900. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  2901. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  2902. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  2903. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  2904. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  2905. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  2906. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  2907. }
  2908. }
  2909. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e3][f3].x && event.motion.x <= PointHaut[e3][f3].x && event.motion.y <= PointMid[e3][f3].y && event.motion.y >= PointHaut[e3][f3].y)
  2910. {
  2911. while (dragAndDrop)
  2912. {
  2913. positionX = event.motion.x; /* On change les coordonnées de la piece */
  2914. posPieceX = posPieceJOff2N3.x;
  2915. posCubikBlue.x = posPieceX;
  2916. posCubeX = posCubikBlue.x;
  2917.  
  2918.  
  2919. positionY = event.motion.y; /* On change les coordonnées de la piece */
  2920. posPieceY = posPieceJOff2N3.y;
  2921. posCubikBlue.y = posPieceY;
  2922. posCubeY = posCubikBlue.y;
  2923.  
  2924. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  2925. {
  2926. posCubikBlue.x = posCubikBlue.x+50;
  2927. posPieceJOff2N3.x = posPieceJOff2N3.x+50;
  2928.  
  2929. posCubikBlue.y = posCubikBlue.y+50;
  2930. posPieceJOff2N3.y = posPieceJOff2N3.y+50;
  2931. }
  2932. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  2933. {
  2934. posCubikBlue.x = posCubikBlue.x+50;
  2935. posPieceJOff2N3.x = posPieceJOff2N3.x+50;
  2936.  
  2937. posCubikBlue.y = posCubikBlue.y-50;
  2938. posPieceJOff2N3.y = posPieceJOff2N3.y-50;
  2939. }
  2940.  
  2941. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  2942. {
  2943. posCubikBlue.x = posCubikBlue.x-50;
  2944. posPieceJOff2N3.x = posPieceJOff2N3.x-50;
  2945.  
  2946. posCubikBlue.y = posCubikBlue.y-50;
  2947. posPieceJOff2N3.y = posPieceJOff2N3.y-50;
  2948. }
  2949. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  2950. {
  2951. posCubikBlue.x = posCubikBlue.x-50;
  2952. posPieceJOff2N3.x = posPieceJOff2N3.x-50;
  2953.  
  2954. posCubikBlue.y = posCubikBlue.y+50;
  2955. posPieceJOff2N3.y = posPieceJOff2N3.y+50;
  2956. }
  2957.  
  2958. SDL_ShowCursor(SDL_DISABLE);
  2959.  
  2960. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  2961. switch(event.type) /* On teste le type d'évènement */
  2962. {
  2963. case SDL_MOUSEBUTTONUP:
  2964.  
  2965. for(j=0 ; j<=15 ; j++)
  2966. {
  2967. for (i=0 ; i<=15 ; i++)
  2968. {
  2969. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  2970. {
  2971. posPieceJOff2N3.x = PosCasesJ2[i][j].x;
  2972. posPieceJOff2N3.y = PosCasesJ2[i][j].y;
  2973. }
  2974. }
  2975. }
  2976.  
  2977. SDL_ShowCursor(SDL_ENABLE);
  2978. dragAndDrop = 0;
  2979. break;
  2980. }
  2981.  
  2982. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  2983. if(compteurFond == 0)
  2984. {
  2985. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  2986. }
  2987. else if(compteurFond == 1)
  2988. {
  2989. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  2990. }
  2991. else if(compteurFond == 2)
  2992. {
  2993. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  2994. }
  2995. else if(compteurFond == 3)
  2996. {
  2997. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  2998. }
  2999. else
  3000. {
  3001. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3002. }
  3003.  
  3004. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3005. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3006. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3007. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3008. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3009. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3010. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3011. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3012. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3013. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3014. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3015. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3016. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3017. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3018. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3019. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3020. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3021. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3022. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3023. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3024. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3025. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3026. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3027. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3028. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3029. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3030. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3031. }
  3032. }
  3033. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e4][f4].x && event.motion.x <= PointHaut[e4][f4].x && event.motion.y <= PointMid[e4][f4].y && event.motion.y >= PointHaut[e4][f4].y)
  3034. {
  3035. while (dragAndDrop)
  3036. {
  3037. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3038. posPieceX = posPieceJOff2N4.x;
  3039. posCubikBlue.x = posPieceX;
  3040. posCubeX = posCubikBlue.x;
  3041.  
  3042.  
  3043. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3044. posPieceY = posPieceJOff2N4.y;
  3045. posCubikBlue.y = posPieceY;
  3046. posCubeY = posCubikBlue.y;
  3047.  
  3048. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3049. {
  3050. posCubikBlue.x = posCubikBlue.x+50;
  3051. posPieceJOff2N4.x = posPieceJOff2N4.x+50;
  3052.  
  3053. posCubikBlue.y = posCubikBlue.y+50;
  3054. posPieceJOff2N4.y = posPieceJOff2N4.y+50;
  3055. }
  3056. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3057. {
  3058. posCubikBlue.x = posCubikBlue.x+50;
  3059. posPieceJOff2N4.x = posPieceJOff2N4.x+50;
  3060.  
  3061. posCubikBlue.y = posCubikBlue.y-50;
  3062. posPieceJOff2N4.y = posPieceJOff2N4.y-50;
  3063. }
  3064.  
  3065. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3066. {
  3067. posCubikBlue.x = posCubikBlue.x-50;
  3068. posPieceJOff2N4.x = posPieceJOff2N4.x-50;
  3069.  
  3070. posCubikBlue.y = posCubikBlue.y-50;
  3071. posPieceJOff2N4.y = posPieceJOff2N4.y-50;
  3072. }
  3073. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3074. {
  3075. posCubikBlue.x = posCubikBlue.x-50;
  3076. posPieceJOff2N4.x = posPieceJOff2N4.x-50;
  3077.  
  3078. posCubikBlue.y = posCubikBlue.y+50;
  3079. posPieceJOff2N4.y = posPieceJOff2N4.y+50;
  3080. }
  3081.  
  3082. SDL_ShowCursor(SDL_DISABLE);
  3083.  
  3084. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3085. switch(event.type) /* On teste le type d'évènement */
  3086. {
  3087. case SDL_MOUSEBUTTONUP:
  3088.  
  3089. for(j=0 ; j<=15 ; j++)
  3090. {
  3091. for (i=0 ; i<=15 ; i++)
  3092. {
  3093. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3094. {
  3095. posPieceJOff2N4.x = PosCasesJ2[i][j].x;
  3096. posPieceJOff2N4.y = PosCasesJ2[i][j].y;
  3097. }
  3098. }
  3099. }
  3100.  
  3101. SDL_ShowCursor(SDL_ENABLE);
  3102. dragAndDrop = 0;
  3103. break;
  3104. }
  3105.  
  3106. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3107. if(compteurFond == 0)
  3108. {
  3109. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3110. }
  3111. else if(compteurFond == 1)
  3112. {
  3113. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3114. }
  3115. else if(compteurFond == 2)
  3116. {
  3117. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3118. }
  3119. else if(compteurFond == 3)
  3120. {
  3121. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3122. }
  3123. else
  3124. {
  3125. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3126. }
  3127.  
  3128. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3129. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3130. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3131. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3132. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3133. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3134. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3135. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3136. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3137. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3138. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3139. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3140. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3141. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3142. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3143. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3144. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3145. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3146. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3147. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3148. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3149. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3150. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3151. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3152. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3153. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3154. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3155. }
  3156. }
  3157. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e5][f5].x && event.motion.x <= PointHaut[e5][f5].x && event.motion.y <= PointMid[e5][f5].y && event.motion.y >= PointHaut[e5][f5].y)
  3158. {
  3159. while (dragAndDrop)
  3160. {
  3161. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3162. posPieceX = posPieceJOff2N5.x;
  3163. posCubikBlue.x = posPieceX;
  3164. posCubeX = posCubikBlue.x;
  3165.  
  3166.  
  3167. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3168. posPieceY = posPieceJOff2N5.y;
  3169. posCubikBlue.y = posPieceY;
  3170. posCubeY = posCubikBlue.y;
  3171.  
  3172. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3173. {
  3174. posCubikBlue.x = posCubikBlue.x+50;
  3175. posPieceJOff2N5.x = posPieceJOff2N5.x+50;
  3176.  
  3177. posCubikBlue.y = posCubikBlue.y+50;
  3178. posPieceJOff2N5.y = posPieceJOff2N5.y+50;
  3179. }
  3180. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3181. {
  3182. posCubikBlue.x = posCubikBlue.x+50;
  3183. posPieceJOff2N5.x = posPieceJOff2N5.x+50;
  3184.  
  3185. posCubikBlue.y = posCubikBlue.y-50;
  3186. posPieceJOff2N5.y = posPieceJOff2N5.y-50;
  3187. }
  3188.  
  3189. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3190. {
  3191. posCubikBlue.x = posCubikBlue.x-50;
  3192. posPieceJOff2N5.x = posPieceJOff2N5.x-50;
  3193.  
  3194. posCubikBlue.y = posCubikBlue.y-50;
  3195. posPieceJOff2N5.y = posPieceJOff2N5.y-50;
  3196. }
  3197. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3198. {
  3199. posCubikBlue.x = posCubikBlue.x-50;
  3200. posPieceJOff2N5.x = posPieceJOff2N5.x-50;
  3201.  
  3202. posCubikBlue.y = posCubikBlue.y+50;
  3203. posPieceJOff2N5.y = posPieceJOff2N5.y+50;
  3204. }
  3205.  
  3206. SDL_ShowCursor(SDL_DISABLE);
  3207.  
  3208. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3209. switch(event.type) /* On teste le type d'évènement */
  3210. {
  3211. case SDL_MOUSEBUTTONUP:
  3212.  
  3213. for(j=0 ; j<=15 ; j++)
  3214. {
  3215. for (i=0 ; i<=15 ; i++)
  3216. {
  3217. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3218. {
  3219. posPieceJOff2N5.x = PosCasesJ2[i][j].x;
  3220. posPieceJOff2N5.y = PosCasesJ2[i][j].y;
  3221. }
  3222. }
  3223. }
  3224.  
  3225. SDL_ShowCursor(SDL_ENABLE);
  3226. dragAndDrop = 0;
  3227. break;
  3228. }
  3229.  
  3230. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3231. if(compteurFond == 0)
  3232. {
  3233. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3234. }
  3235. else if(compteurFond == 1)
  3236. {
  3237. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3238. }
  3239. else if(compteurFond == 2)
  3240. {
  3241. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3242. }
  3243. else if(compteurFond == 3)
  3244. {
  3245. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3246. }
  3247. else
  3248. {
  3249. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3250. }
  3251.  
  3252. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3253. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3254. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3255. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3256. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3257. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3258. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3259. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3260. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3261. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3262. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3263. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3264. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3265. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3266. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3267. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3268. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3269. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3270. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3271. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3272. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3273. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3274. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3275. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3276. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3277. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3278. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3279. }
  3280. }
  3281. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[e6][f6].x && event.motion.x <= PointHaut[e6][f6].x && event.motion.y <= PointMid[e6][f6].y && event.motion.y >= PointHaut[e6][f6].y)
  3282. {
  3283. while (dragAndDrop)
  3284. {
  3285. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3286. posPieceX = posPieceJOff2N6.x;
  3287. posCubikBlue.x = posPieceX;
  3288. posCubeX = posCubikBlue.x;
  3289.  
  3290.  
  3291. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3292. posPieceY = posPieceJOff2N6.y;
  3293. posCubikBlue.y = posPieceY;
  3294. posCubeY = posCubikBlue.y;
  3295.  
  3296. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3297. {
  3298. posCubikBlue.x = posCubikBlue.x+50;
  3299. posPieceJOff2N6.x = posPieceJOff2N6.x+50;
  3300.  
  3301. posCubikBlue.y = posCubikBlue.y+50;
  3302. posPieceJOff2N6.y = posPieceJOff2N6.y+50;
  3303. }
  3304. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3305. {
  3306. posCubikBlue.x = posCubikBlue.x+50;
  3307. posPieceJOff2N6.x = posPieceJOff2N6.x+50;
  3308.  
  3309. posCubikBlue.y = posCubikBlue.y-50;
  3310. posPieceJOff2N6.y = posPieceJOff2N6.y-50;
  3311. }
  3312.  
  3313. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3314. {
  3315. posCubikBlue.x = posCubikBlue.x-50;
  3316. posPieceJOff2N6.x = posPieceJOff2N6.x-50;
  3317.  
  3318. posCubikBlue.y = posCubikBlue.y-50;
  3319. posPieceJOff2N6.y = posPieceJOff2N6.y-50;
  3320. }
  3321. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3322. {
  3323. posCubikBlue.x = posCubikBlue.x-50;
  3324. posPieceJOff2N6.x = posPieceJOff2N6.x-50;
  3325.  
  3326. posCubikBlue.y = posCubikBlue.y+50;
  3327. posPieceJOff2N6.y = posPieceJOff2N6.y+50;
  3328. }
  3329.  
  3330. SDL_ShowCursor(SDL_DISABLE);
  3331.  
  3332. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3333. switch(event.type) /* On teste le type d'évènement */
  3334. {
  3335. case SDL_MOUSEBUTTONUP:
  3336.  
  3337. for(j=0 ; j<=15 ; j++)
  3338. {
  3339. for (i=0 ; i<=15 ; i++)
  3340. {
  3341. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3342. {
  3343. posPieceJOff2N6.x = PosCasesJ2[i][j].x;
  3344. posPieceJOff2N6.y = PosCasesJ2[i][j].y;
  3345. }
  3346. }
  3347. }
  3348.  
  3349. SDL_ShowCursor(SDL_ENABLE);
  3350. dragAndDrop = 0;
  3351. break;
  3352. }
  3353.  
  3354. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3355. if(compteurFond == 0)
  3356. {
  3357. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3358. }
  3359. else if(compteurFond == 1)
  3360. {
  3361. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3362. }
  3363. else if(compteurFond == 2)
  3364. {
  3365. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3366. }
  3367. else if(compteurFond == 3)
  3368. {
  3369. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3370. }
  3371. else
  3372. {
  3373. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3374. }
  3375.  
  3376. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3377. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3378. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3379. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3380. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3381. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3382. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3383. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3384. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3385. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3386. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3387. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3388. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3389. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3390. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3391. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3392. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3393. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3394. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3395. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3396. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3397. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3398. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3399. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3400. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3401. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3402. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3403. }
  3404. }
  3405. //on passe au piece defensive du joueur2//
  3406. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g1][h1].x && event.motion.x <= PointHaut[g1][h1].x && event.motion.y <= PointMid[g1][h1].y && event.motion.y >= PointHaut[g1][h1].y)
  3407. {
  3408. while (dragAndDrop)
  3409. {
  3410. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3411. posPieceX = posPieceJDef2N1.x;
  3412. posCubikBlue.x = posPieceX;
  3413. posCubeX = posCubikBlue.x;
  3414.  
  3415.  
  3416. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3417. posPieceY = posPieceJDef2N1.y;
  3418. posCubikBlue.y = posPieceY;
  3419. posCubeY = posCubikBlue.y;
  3420.  
  3421. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3422. {
  3423. posCubikBlue.x = posCubikBlue.x+50;
  3424. posPieceJDef2N1.x = posPieceJDef2N1.x+50;
  3425.  
  3426. posCubikBlue.y = posCubikBlue.y+50;
  3427. posPieceJDef2N1.y = posPieceJDef2N1.y+50;
  3428. }
  3429. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3430. {
  3431. posCubikBlue.x = posCubikBlue.x+50;
  3432. posPieceJDef2N1.x = posPieceJDef2N1.x+50;
  3433.  
  3434. posCubikBlue.y = posCubikBlue.y-50;
  3435. posPieceJDef2N1.y = posPieceJDef2N1.y-50;
  3436. }
  3437.  
  3438. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3439. {
  3440. posCubikBlue.x = posCubikBlue.x-50;
  3441. posPieceJDef2N1.x = posPieceJDef2N1.x-50;
  3442.  
  3443. posCubikBlue.y = posCubikBlue.y-50;
  3444. posPieceJDef2N1.y = posPieceJDef2N1.y-50;
  3445. }
  3446. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3447. {
  3448. posCubikBlue.x = posCubikBlue.x-50;
  3449. posPieceJDef2N1.x = posPieceJDef2N1.x-50;
  3450.  
  3451. posCubikBlue.y = posCubikBlue.y+50;
  3452. posPieceJDef2N1.y = posPieceJDef2N1.y+50;
  3453. }
  3454.  
  3455.  
  3456. SDL_ShowCursor(SDL_DISABLE);
  3457.  
  3458. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3459. switch(event.type) /* On teste le type d'évènement */
  3460. {
  3461. case SDL_MOUSEBUTTONUP:
  3462.  
  3463. for(j=0 ; j<=15 ; j++)
  3464. {
  3465. for (i=0 ; i<=15 ; i++)
  3466. {
  3467. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y >= PointMid[i][j].y && event.motion.y <= PointHaut[i][j].y)
  3468. {
  3469. posPieceJDef2N1.x = PosCasesJ2[i][j].x;
  3470. posPieceJDef2N1.y = PosCasesJ2[i][j].y;
  3471. }
  3472. }
  3473. }
  3474.  
  3475. SDL_ShowCursor(SDL_ENABLE);
  3476. dragAndDrop = 0;
  3477. break;
  3478. }
  3479.  
  3480. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3481. if(compteurFond == 0)
  3482. {
  3483. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3484. }
  3485. else if(compteurFond == 1)
  3486. {
  3487. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3488. }
  3489. else if(compteurFond == 2)
  3490. {
  3491. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3492. }
  3493. else if(compteurFond == 3)
  3494. {
  3495. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3496. }
  3497. else
  3498. {
  3499. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3500. }
  3501.  
  3502. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3503. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3504. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3505. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3506. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3507. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3508. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3509. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3510. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3511. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3512. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3513. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3514. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3515. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3516. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3517. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3518. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3519. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3520. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3521. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3522. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3523. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3524. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3525. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3526. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3527. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3528. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3529. }
  3530. }
  3531. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g2][h2].x && event.motion.x <= PointHaut[g2][h2].x && event.motion.y <= PointMid[g2][h2].y && event.motion.y >= PointHaut[g2][h2].y)
  3532. {
  3533. while (dragAndDrop)
  3534. {
  3535. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3536. posPieceX = posPieceJDef2N2.x;
  3537. posCubikBlue.x = posPieceX;
  3538. posCubeX = posCubikBlue.x;
  3539.  
  3540.  
  3541. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3542. posPieceY = posPieceJDef2N2.y;
  3543. posCubikBlue.y = posPieceY;
  3544. posCubeY = posCubikBlue.y;
  3545.  
  3546. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3547. {
  3548. posCubikBlue.x = posCubikBlue.x+50;
  3549. posPieceJDef2N2.x = posPieceJDef2N2.x+50;
  3550.  
  3551. posCubikBlue.y = posCubikBlue.y+50;
  3552. posPieceJDef2N2.y = posPieceJDef2N2.y+50;
  3553. }
  3554. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3555. {
  3556. posCubikBlue.x = posCubikBlue.x+50;
  3557. posPieceJDef2N2.x = posPieceJDef2N2.x+50;
  3558.  
  3559. posCubikBlue.y = posCubikBlue.y-50;
  3560. posPieceJDef2N2.y = posPieceJDef2N2.y-50;
  3561. }
  3562.  
  3563. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3564. {
  3565. posCubikBlue.x = posCubikBlue.x-50;
  3566. posPieceJDef2N2.x = posPieceJDef2N2.x-50;
  3567.  
  3568. posCubikBlue.y = posCubikBlue.y-50;
  3569. posPieceJDef2N2.y = posPieceJDef2N2.y-50;
  3570. }
  3571. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3572. {
  3573. posCubikBlue.x = posCubikBlue.x-50;
  3574. posPieceJDef2N2.x = posPieceJDef2N2.x-50;
  3575.  
  3576. posCubikBlue.y = posCubikBlue.y+50;
  3577. posPieceJDef2N2.y = posPieceJDef2N2.y+50;
  3578. }
  3579.  
  3580. SDL_ShowCursor(SDL_DISABLE);
  3581.  
  3582. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3583. switch(event.type) /* On teste le type d'évènement */
  3584. {
  3585. case SDL_MOUSEBUTTONUP:
  3586.  
  3587. for(j=0 ; j<=15 ; j++)
  3588. {
  3589. for (i=0 ; i<=15 ; i++)
  3590. {
  3591. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3592. {
  3593. posPieceJDef2N2.x = PosCasesJ2[i][j].x;
  3594. posPieceJDef2N2.y = PosCasesJ2[i][j].y;
  3595. }
  3596. }
  3597. }
  3598.  
  3599. SDL_ShowCursor(SDL_ENABLE);
  3600. dragAndDrop = 0;
  3601. break;
  3602. }
  3603.  
  3604. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3605. if(compteurFond == 0)
  3606. {
  3607. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3608. }
  3609. else if(compteurFond == 1)
  3610. {
  3611. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3612. }
  3613. else if(compteurFond == 2)
  3614. {
  3615. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3616. }
  3617. else if(compteurFond == 3)
  3618. {
  3619. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3620. }
  3621. else
  3622. {
  3623. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3624. }
  3625.  
  3626. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3627. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3628. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3629. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3630. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3631. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3632. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3633. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3634. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3635. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3636. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3637. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3638. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3639. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3640. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3641. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3642. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3643. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3644. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3645. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3646. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3647. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3648. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3649. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3650. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3651. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3652. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3653. }
  3654. }
  3655. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g3][h3].x && event.motion.x <= PointHaut[g3][h3].x && event.motion.y <= PointMid[g3][h3].y && event.motion.y >= PointHaut[g3][h3].y)
  3656. {
  3657. while (dragAndDrop)
  3658. {
  3659. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3660. posPieceX = posPieceJDef2N3.x;
  3661. posCubikBlue.x = posPieceX;
  3662. posCubeX = posCubikBlue.x;
  3663.  
  3664.  
  3665. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3666. posPieceY = posPieceJDef2N3.y;
  3667. posCubikBlue.y = posPieceY;
  3668. posCubeY = posCubikBlue.y;
  3669.  
  3670. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3671. {
  3672. posCubikBlue.x = posCubikBlue.x+50;
  3673. posPieceJDef2N3.x = posPieceJDef2N3.x+50;
  3674.  
  3675. posCubikBlue.y = posCubikBlue.y+50;
  3676. posPieceJDef2N3.y = posPieceJDef2N3.y+50;
  3677. }
  3678. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3679. {
  3680. posCubikBlue.x = posCubikBlue.x+50;
  3681. posPieceJDef2N3.x = posPieceJDef2N3.x+50;
  3682.  
  3683. posCubikBlue.y = posCubikBlue.y-50;
  3684. posPieceJDef2N3.y = posPieceJDef2N3.y-50;
  3685. }
  3686.  
  3687. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3688. {
  3689. posCubikBlue.x = posCubikBlue.x-50;
  3690. posPieceJDef2N3.x = posPieceJDef2N3.x-50;
  3691.  
  3692. posCubikBlue.y = posCubikBlue.y-50;
  3693. posPieceJDef2N3.y = posPieceJDef2N3.y-50;
  3694. }
  3695. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3696. {
  3697. posCubikBlue.x = posCubikBlue.x-50;
  3698. posPieceJDef2N3.x = posPieceJDef2N3.x-50;
  3699.  
  3700. posCubikBlue.y = posCubikBlue.y+50;
  3701. posPieceJDef2N3.y = posPieceJDef2N3.y+50;
  3702. }
  3703.  
  3704. SDL_ShowCursor(SDL_DISABLE);
  3705.  
  3706. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3707. switch(event.type) /* On teste le type d'évènement */
  3708. {
  3709. case SDL_MOUSEBUTTONUP:
  3710.  
  3711. for(j=0 ; j<=15 ; j++)
  3712. {
  3713. for (i=0 ; i<=15 ; i++)
  3714. {
  3715. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3716. {
  3717. posPieceJDef2N3.x = PosCasesJ2[i][j].x;
  3718. posPieceJDef2N3.y = PosCasesJ2[i][j].y;
  3719. }
  3720. }
  3721. }
  3722.  
  3723. SDL_ShowCursor(SDL_ENABLE);
  3724. dragAndDrop = 0;
  3725. break;
  3726. }
  3727.  
  3728. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3729. if(compteurFond == 0)
  3730. {
  3731. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3732. }
  3733. else if(compteurFond == 1)
  3734. {
  3735. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3736. }
  3737. else if(compteurFond == 2)
  3738. {
  3739. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3740. }
  3741. else if(compteurFond == 3)
  3742. {
  3743. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3744. }
  3745. else
  3746. {
  3747. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3748. }
  3749.  
  3750. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3751. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3752. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3753. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3754. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3755. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3756. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3757. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3758. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3759. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3760. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3761. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3762. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3763. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3764. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3765. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3766. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3767. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3768. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3769. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3770. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3771. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3772. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3773. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3774. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3775. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3776. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3777. }
  3778. }
  3779. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g4][h4].x && event.motion.x <= PointHaut[g4][h4].x && event.motion.y <= PointMid[g4][h4].y && event.motion.y >= PointHaut[g4][h4].y)
  3780. {
  3781. while (dragAndDrop)
  3782. {
  3783. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3784. posPieceX = posPieceJDef2N4.x;
  3785. posCubikBlue.x = posPieceX;
  3786. posCubeX = posCubikBlue.x;
  3787.  
  3788.  
  3789. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3790. posPieceY = posPieceJDef2N4.y;
  3791. posCubikBlue.y = posPieceY;
  3792. posCubeY = posCubikBlue.y;
  3793.  
  3794. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3795. {
  3796. posCubikBlue.x = posCubikBlue.x+50;
  3797. posPieceJDef2N4.x = posPieceJDef2N4.x+50;
  3798.  
  3799. posCubikBlue.y = posCubikBlue.y+50;
  3800. posPieceJDef2N4.y = posPieceJDef2N4.y+50;
  3801. }
  3802. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3803. {
  3804. posCubikBlue.x = posCubikBlue.x+50;
  3805. posPieceJDef2N4.x = posPieceJDef2N4.x+50;
  3806.  
  3807. posCubikBlue.y = posCubikBlue.y-50;
  3808. posPieceJDef2N4.y = posPieceJDef2N4.y-50;
  3809. }
  3810.  
  3811. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3812. {
  3813. posCubikBlue.x = posCubikBlue.x-50;
  3814. posPieceJDef2N4.x = posPieceJDef2N4.x-50;
  3815.  
  3816. posCubikBlue.y = posCubikBlue.y-50;
  3817. posPieceJDef2N4.y = posPieceJDef2N4.y-50;
  3818. }
  3819. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3820. {
  3821. posCubikBlue.x = posCubikBlue.x-50;
  3822. posPieceJDef2N4.x = posPieceJDef2N4.x-50;
  3823.  
  3824. posCubikBlue.y = posCubikBlue.y+50;
  3825. posPieceJDef2N4.y = posPieceJDef2N4.y+50;
  3826. }
  3827.  
  3828. SDL_ShowCursor(SDL_DISABLE);
  3829.  
  3830. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3831. switch(event.type) /* On teste le type d'évènement */
  3832. {
  3833. case SDL_MOUSEBUTTONUP:
  3834.  
  3835. for(j=0 ; j<=15 ; j++)
  3836. {
  3837. for (i=0 ; i<=15 ; i++)
  3838. {
  3839. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3840. {
  3841. posPieceJDef2N4.x = PosCasesJ2[i][j].x;
  3842. posPieceJDef2N4.y = PosCasesJ2[i][j].y;
  3843. }
  3844. }
  3845. }
  3846.  
  3847. SDL_ShowCursor(SDL_ENABLE);
  3848. dragAndDrop = 0;
  3849. break;
  3850. }
  3851.  
  3852. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3853. if(compteurFond == 0)
  3854. {
  3855. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3856. }
  3857. else if(compteurFond == 1)
  3858. {
  3859. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3860. }
  3861. else if(compteurFond == 2)
  3862. {
  3863. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3864. }
  3865. else if(compteurFond == 3)
  3866. {
  3867. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3868. }
  3869. else
  3870. {
  3871. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3872. }
  3873.  
  3874. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3875. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  3876. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  3877. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  3878. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  3879. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  3880. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  3881. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  3882. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  3883. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  3884. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  3885. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  3886. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  3887. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  3888. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  3889. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  3890. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  3891. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  3892. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  3893. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  3894. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  3895. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  3896. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  3897. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  3898. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  3899. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  3900. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  3901. }
  3902. }
  3903. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g5][h5].x && event.motion.x <= PointHaut[g5][h5].x && event.motion.y <= PointMid[g5][h5].y && event.motion.y >= PointHaut[g5][h5].y)
  3904. {
  3905. while (dragAndDrop)
  3906. {
  3907. positionX = event.motion.x; /* On change les coordonnées de la piece */
  3908. posPieceX = posPieceJDef2N5.x;
  3909. posCubikBlue.x = posPieceX;
  3910. posCubeX = posCubikBlue.x;
  3911.  
  3912.  
  3913. positionY = event.motion.y; /* On change les coordonnées de la piece */
  3914. posPieceY = posPieceJDef2N5.y;
  3915. posCubikBlue.y = posPieceY;
  3916. posCubeY = posCubikBlue.y;
  3917.  
  3918. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  3919. {
  3920. posCubikBlue.x = posCubikBlue.x+50;
  3921. posPieceJDef2N5.x = posPieceJDef2N5.x+50;
  3922.  
  3923. posCubikBlue.y = posCubikBlue.y+50;
  3924. posPieceJDef2N5.y = posPieceJDef2N5.y+50;
  3925. }
  3926. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  3927. {
  3928. posCubikBlue.x = posCubikBlue.x+50;
  3929. posPieceJDef2N5.x = posPieceJDef2N5.x+50;
  3930.  
  3931. posCubikBlue.y = posCubikBlue.y-50;
  3932. posPieceJDef2N5.y = posPieceJDef2N5.y-50;
  3933. }
  3934.  
  3935. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  3936. {
  3937. posCubikBlue.x = posCubikBlue.x-50;
  3938. posPieceJDef2N5.x = posPieceJDef2N5.x-50;
  3939.  
  3940. posCubikBlue.y = posCubikBlue.y-50;
  3941. posPieceJDef2N5.y = posPieceJDef2N5.y-50;
  3942. }
  3943. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  3944. {
  3945. posCubikBlue.x = posCubikBlue.x-50;
  3946. posPieceJDef2N5.x = posPieceJDef2N5.x-50;
  3947.  
  3948. posCubikBlue.y = posCubikBlue.y+50;
  3949. posPieceJDef2N5.y = posPieceJDef2N5.y+50;
  3950. }
  3951.  
  3952. SDL_ShowCursor(SDL_DISABLE);
  3953.  
  3954. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  3955. switch(event.type) /* On teste le type d'évènement */
  3956. {
  3957. case SDL_MOUSEBUTTONUP:
  3958.  
  3959. for(j=0 ; j<=15 ; j++)
  3960. {
  3961. for (i=0 ; i<=15 ; i++)
  3962. {
  3963. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  3964. {
  3965. posPieceJDef2N5.x = PosCasesJ2[i][j].x;
  3966. posPieceJDef2N5.y = PosCasesJ2[i][j].y;
  3967. }
  3968. }
  3969. }
  3970.  
  3971. SDL_ShowCursor(SDL_ENABLE);
  3972. dragAndDrop = 0;
  3973. break;
  3974. }
  3975.  
  3976. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  3977. if(compteurFond == 0)
  3978. {
  3979. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  3980. }
  3981. else if(compteurFond == 1)
  3982. {
  3983. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  3984. }
  3985. else if(compteurFond == 2)
  3986. {
  3987. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  3988. }
  3989. else if(compteurFond == 3)
  3990. {
  3991. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  3992. }
  3993. else
  3994. {
  3995. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  3996. }
  3997.  
  3998. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  3999. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  4000. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  4001. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  4002. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  4003. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4004. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4005. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4006. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4007. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4008. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4009. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4010. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4011. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4012. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4013. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4014. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4015. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4016. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4017. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4018. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  4019. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  4020. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  4021. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  4022. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  4023. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  4024. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4025. }
  4026. }
  4027. else if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[g6][h6].x && event.motion.x <= PointHaut[g6][h6].x && event.motion.y <= PointMid[g6][h6].y && event.motion.y >= PointHaut[g6][h6].y)
  4028. {
  4029. while (dragAndDrop)
  4030. {
  4031. positionX = event.motion.x; /* On change les coordonnées de la piece */
  4032. posPieceX = posPieceJDef2N6.x;
  4033. posCubikBlue.x = posPieceX;
  4034. posCubeX = posCubikBlue.x;
  4035.  
  4036.  
  4037. positionY = event.motion.y; /* On change les coordonnées de la piece */
  4038. posPieceY = posPieceJDef2N6.y;
  4039. posCubikBlue.y = posPieceY;
  4040. posCubeY = posCubikBlue.y;
  4041.  
  4042. if(positionX-25 > posPieceX && positionY-25 > posPieceY)
  4043. {
  4044. posCubikBlue.x = posCubikBlue.x+50;
  4045. posPieceJDef2N6.x = posPieceJDef2N6.x+50;
  4046.  
  4047. posCubikBlue.y = posCubikBlue.y+50;
  4048. posPieceJDef2N6.y = posPieceJDef2N6.y+50;
  4049. }
  4050. else if(positionX-25 > posPieceX && positionY+25 < posPieceY)
  4051. {
  4052. posCubikBlue.x = posCubikBlue.x+50;
  4053. posPieceJDef2N6.x = posPieceJDef2N6.x+50;
  4054.  
  4055. posCubikBlue.y = posCubikBlue.y-50;
  4056. posPieceJDef2N6.y = posPieceJDef2N6.y-50;
  4057. }
  4058.  
  4059. else if(positionX-25 < posPieceX && positionY+25 < posPieceY)
  4060. {
  4061. posCubikBlue.x = posCubikBlue.x-50;
  4062. posPieceJDef2N6.x = posPieceJDef2N6.x-50;
  4063.  
  4064. posCubikBlue.y = posCubikBlue.y-50;
  4065. posPieceJDef2N6.y = posPieceJDef2N6.y-50;
  4066. }
  4067. else if(positionX-25 < posPieceX && positionY-25 > posPieceY)
  4068. {
  4069. posCubikBlue.x = posCubikBlue.x-50;
  4070. posPieceJDef2N6.x = posPieceJDef2N6.x-50;
  4071.  
  4072. posCubikBlue.y = posCubikBlue.y+50;
  4073. posPieceJDef2N6.y = posPieceJDef2N6.y+50;
  4074. }
  4075.  
  4076. SDL_ShowCursor(SDL_DISABLE);
  4077.  
  4078. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4079. switch(event.type) /* On teste le type d'évènement */
  4080. {
  4081. case SDL_MOUSEBUTTONUP:
  4082.  
  4083. for(j=0 ; j<=15 ; j++)
  4084. {
  4085. for (i=0 ; i<=15 ; i++)
  4086. {
  4087. if(event.button.button == SDL_BUTTON_LEFT && event.motion.x >= PointMid[i][j].x && event.motion.x <= PointHaut[i][j].x && event.motion.y <= PointMid[i][j].y && event.motion.y >= PointHaut[i][j].y)
  4088. {
  4089. posPieceJDef2N6.x = PosCasesJ2[i][j].x;
  4090. posPieceJDef2N6.y = PosCasesJ2[i][j].y;
  4091. }
  4092. }
  4093. }
  4094.  
  4095. SDL_ShowCursor(SDL_ENABLE);
  4096. dragAndDrop = 0;
  4097. break;
  4098. }
  4099.  
  4100. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4101. if(compteurFond == 0)
  4102. {
  4103. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  4104. }
  4105. else if(compteurFond == 1)
  4106. {
  4107. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  4108. }
  4109. else if(compteurFond == 2)
  4110. {
  4111. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  4112. }
  4113. else if(compteurFond == 3)
  4114. {
  4115. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  4116. }
  4117. else
  4118. {
  4119. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  4120. }
  4121.  
  4122. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  4123. SDL_BlitSurface(CubikBlue, NULL, ecran, &posCubikBlue);
  4124. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  4125. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  4126. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  4127. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4128. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4129. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4130. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4131. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4132. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4133. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4134. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4135. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4136. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4137. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4138. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4139. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4140. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4141. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4142. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  4143. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  4144. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  4145. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  4146. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  4147. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  4148. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4149. }
  4150. }
  4151. }
  4152. //default:
  4153. //break;
  4154.  
  4155.  
  4156. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4157.  
  4158. switch (compteurFond)
  4159. {
  4160. case 0:
  4161. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  4162. break;
  4163.  
  4164. case 1:
  4165. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  4166. break;
  4167.  
  4168. case 2:
  4169. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet);
  4170. break;
  4171.  
  4172. case 3:
  4173. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage);
  4174. break;
  4175.  
  4176. case 4:
  4177. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  4178. break;
  4179.  
  4180. default:
  4181. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  4182. break;
  4183. }
  4184.  
  4185. if(compteurDebut == 0)
  4186. {
  4187. SDL_BlitSurface(textJ1Commence, NULL, ecran, &PointMid[3][3]);
  4188. compteurDebut--;
  4189. }
  4190.  
  4191. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  4192. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  4193. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  4194. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  4195. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4196. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4197. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4198. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4199. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4200. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4201. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4202. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4203. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4204. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4205. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4206. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4207. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4208. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4209. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4210. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  4211. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  4212. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  4213. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  4214. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  4215. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  4216. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4217. }
  4218. }
  4219.  
  4220. //quand le pointeur est sur le menu 2 joueurs
  4221. else if (posSelectMenu.y >=250 && posSelectMenu.y<300)
  4222. {
  4223. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  4224. {
  4225. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4226. switch(event.type) /* On teste le type d'évènement */
  4227. {
  4228. case SDL_KEYDOWN:
  4229. switch(event.key.keysym.sym)
  4230. {
  4231. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4232. continuer1 = 0;
  4233. default:
  4234. break;
  4235. }
  4236. break;
  4237. }
  4238.  
  4239. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4240. if(compteurFond == 0)
  4241. {
  4242. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  4243. }
  4244. else if(compteurFond == 1)
  4245. {
  4246. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  4247. }
  4248. else if(compteurFond == 2)
  4249. {
  4250. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet); /* On blitte par-dessus l'écran le fond */
  4251. }
  4252. else if(compteurFond == 3)
  4253. {
  4254. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage); /* On blitte par-dessus l'écran le fond */
  4255. }
  4256. else
  4257. {
  4258. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  4259. }
  4260. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  4261. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  4262. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  4263. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  4264. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4265. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4266. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4267. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4268. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4269. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4270. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4271. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4272. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4273. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4274. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4275. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4276. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4277. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4278. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4279. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  4280. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  4281. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  4282. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4283. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4284. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4285. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4286. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4287. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4288. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4289. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4290. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4291. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4292. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4293. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4294. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4295. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4296. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4297. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N1);
  4298. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N2);
  4299. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N3);
  4300. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N4);
  4301. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  4302. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  4303. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4304. }
  4305. break;
  4306.  
  4307. }
  4308.  
  4309. //quand le pointeur est sur le menu 2 joueurs
  4310. else if (posSelectMenu.y >=250 && posSelectMenu.y<300)
  4311. {
  4312. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  4313. {
  4314. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4315. switch(event.type) /* On teste le type d'évènement */
  4316. {
  4317. case SDL_KEYDOWN:
  4318. switch(event.key.keysym.sym)
  4319. {
  4320. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4321. continuer1 = 0;
  4322. default:
  4323. break;
  4324. }
  4325. break;
  4326. }
  4327.  
  4328. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4329. if(compteurFond == 0)
  4330. {
  4331. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran le fond */
  4332. }
  4333. else if(compteurFond == 1)
  4334. {
  4335. SDL_BlitSurface(textureEtoile, NULL, ecran, &positionEtoile); /* On blitte par-dessus l'écran le fond */
  4336. }
  4337. else if(compteurFond == 2)
  4338. {
  4339. SDL_BlitSurface(textureForet, NULL, ecran, &positionForet); /* On blitte par-dessus l'écran le fond */
  4340. }
  4341. else if(compteurFond == 3)
  4342. {
  4343. SDL_BlitSurface(texturePlage, NULL, ecran, &positionPlage); /* On blitte par-dessus l'écran le fond */
  4344. }
  4345. else
  4346. {
  4347. SDL_BlitSurface(textureNuit, NULL, ecran, &positionNuit); /* On blitte par-dessus l'écran le fond */
  4348. }
  4349. SDL_BlitSurface(damierInc800800NB, NULL, ecran, &posDamInc800800NB);/* On blitte par-dessus l'écran un damier */
  4350. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N1);
  4351. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N2);
  4352. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N3);
  4353. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N4);
  4354. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N5);
  4355. SDL_BlitSurface(pieceJeuOff1N, NULL, ecran, &posPieceJOff1N6);
  4356. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N1);
  4357. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N2);
  4358. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N3);
  4359. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N4);
  4360. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N5);
  4361. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJDef1N6);
  4362. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N1);
  4363. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N2);
  4364. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N3);
  4365. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N4);
  4366. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N5);
  4367. SDL_BlitSurface(pieceJeuOff2N, NULL, ecran, &posPieceJOff2N6);
  4368. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJOff1N1);
  4369. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJOff1N2);
  4370. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJOff1N3);
  4371. SDL_BlitSurface(pieceJeuDef1N, NULL, ecran, &posPieceJOff1N4);
  4372. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N5);
  4373. SDL_BlitSurface(pieceJeuDef2N, NULL, ecran, &posPieceJDef2N6);
  4374. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4375. }
  4376. }
  4377.  
  4378. //quand le pointeur est sur le menu charger une partie
  4379. else if (posSelectMenu.y >=300 && posSelectMenu.y<350)
  4380. {
  4381. posSelectMenu.x = 170;
  4382. posSelectMenu.y = 200;
  4383. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  4384. {
  4385. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4386. switch(event.type) /* On teste le type d'évènement */
  4387. {
  4388. case SDL_KEYDOWN:
  4389. switch (event.key.keysym.sym)
  4390. {
  4391. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4392. continuer1 = 0;
  4393. break;
  4394.  
  4395. case SDLK_UP: // Flèche haut
  4396. if(posSelectMenu.y >=250)
  4397. {
  4398. posSelectMenu.y = posSelectMenu.y-50;
  4399. break;
  4400. }
  4401. break;
  4402.  
  4403. case SDLK_DOWN: // Flèche bas
  4404. if (posSelectMenu.y <=350)
  4405. {
  4406. posSelectMenu.y = posSelectMenu.y+50;
  4407. break;
  4408. }
  4409. default:
  4410. break;
  4411. }
  4412. break;
  4413. }
  4414. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4415. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  4416. SDL_BlitSurface(selectMenu, NULL, ecran, &posSelectMenu);/* On blitte par-dessus l'écran */
  4417. SDL_BlitSurface(ssMenu3, NULL, ecran, &positionSsMenu3); /* Blit du texte charger une partie par-dessus */
  4418. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4419. }
  4420. }
  4421.  
  4422. //quand le pointeur est sur le menu revoir une partie
  4423. else if (posSelectMenu.y >=350 && posSelectMenu.y<400)
  4424. {
  4425. posSelectMenu.x = 170;
  4426. posSelectMenu.y = 250;
  4427. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  4428. {
  4429. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4430. switch(event.type) /* On teste le type d'évènement */
  4431. {
  4432. case SDL_KEYDOWN:
  4433. switch (event.key.keysym.sym)
  4434. {
  4435. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4436. continuer1 = 0;
  4437. break;
  4438.  
  4439. case SDLK_UP: // Flèche haut
  4440. if(posSelectMenu.y >=300)
  4441. {
  4442. posSelectMenu.y = posSelectMenu.y-50;
  4443. break;
  4444. }
  4445. default:
  4446. break;
  4447.  
  4448. case SDLK_DOWN: // Flèche bas
  4449. if (posSelectMenu.y <=400)
  4450. {
  4451. posSelectMenu.y = posSelectMenu.y+50;
  4452. break;
  4453. }
  4454. break;
  4455. }
  4456. break;
  4457. }
  4458. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  4459. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  4460. SDL_BlitSurface(selectMenu, NULL, ecran, &posSelectMenu);/* On blitte par-dessus l'écran */
  4461. SDL_BlitSurface(ssMenu4, NULL, ecran, &positionSsMenu4); /* Blit du texte revoir une partie par-dessus */
  4462. SDL_BlitSurface(texteSelect, NULL, ecran, &posTexteSelect);
  4463. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  4464. }
  4465. }
  4466.  
  4467. //quand le pointeur est sur le menu sur option
  4468. else if (posSelectMenu.y >=400 && posSelectMenu.y<450)
  4469. {
  4470. posSelectMenu.x = 120;
  4471. posSelectMenu.y = 200;
  4472. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  4473. {
  4474. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4475. switch(event.type) /* On teste le type d'évènement */
  4476. {
  4477. case SDL_KEYDOWN:
  4478. switch (event.key.keysym.sym)
  4479. {
  4480. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4481. continuer1 = 0;
  4482. break;
  4483.  
  4484. case SDLK_UP: // Flèche haut
  4485. if(posSelectMenu.y >=250)
  4486. {
  4487. posSelectMenu.y = posSelectMenu.y-50;
  4488. break;
  4489. }
  4490. break;
  4491.  
  4492. case SDLK_DOWN: // Flèche bas
  4493. if (posSelectMenu.y <=250)
  4494. {
  4495. posSelectMenu.y = posSelectMenu.y+50;
  4496. break;
  4497. }
  4498. break;
  4499.  
  4500. case SDLK_RETURN: //on rentre dans le menu Option si on appuie sur ENTRER
  4501. while (continuer2) /* TANT QUE la variable ne vaut pas 0 */
  4502. {
  4503. //Option - réglage des couleurs des pieces
  4504. if(posSelectMenu.y >=200 && (posSelectMenu.y <250))
  4505. {
  4506. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  4507. switch(event.type) /* On teste le type d'évènement */
  4508. {
  4509. case SDL_KEYDOWN:
  4510. switch(event.key.keysym.sym)
  4511. {
  4512. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  4513. continuer2 = 0;
  4514. default:
  4515. break;
  4516. }
  4517. break;
  4518.  
  4519. case SDL_MOUSEBUTTONUP:
  4520. if(event.button.x>=540 && event.button.x<=568 && event.button.y>=180 && event.button.y<=198 && event.button.button == SDL_BUTTON_LEFT && comptR1 > 0)
  4521. {
  4522. comptR1--;
  4523. break;
  4524. }
  4525. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=180 && event.button.y<=198 && event.button.button == SDL_BUTTON_LEFT && comptR1 < 1)
  4526. {
  4527. comptR1++;
  4528. break;
  4529. }
  4530. else if(event.button.x>=540 && event.button.x<=568 && event.button.y>=210 && event.button.y<=228 && event.button.button == SDL_BUTTON_LEFT && comptV1 > 0)
  4531. {
  4532. comptV1--;
  4533. break;
  4534. }
  4535. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=210 && event.button.y<=228 && event.button.button == SDL_BUTTON_LEFT && comptV1 < 1)
  4536. {
  4537. comptV1++;
  4538. break;
  4539. }
  4540. else if(event.button.x>=540 && event.button.x<=568 && event.button.y>=240 && event.button.y<=258 && event.button.button == SDL_BUTTON_LEFT && comptB1 > 0)
  4541. {
  4542. comptB1--;
  4543. break;
  4544. }
  4545. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=240 && event.button.y<=258 && event.button.button == SDL_BUTTON_LEFT && comptB1 < 1)
  4546. {
  4547. comptB1++;
  4548. break;
  4549. }
  4550. else if(event.button.x>=540 && event.button.x<=568 && event.button.y>=330 && event.button.y<=348 && event.button.button == SDL_BUTTON_LEFT && comptR2 > 0)
  4551. {
  4552. comptR2--;
  4553. break;
  4554. }
  4555. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=330 && event.button.y<=348 && event.button.button == SDL_BUTTON_LEFT && comptR2 < 1)
  4556. {
  4557. comptR2++;
  4558. break;
  4559. }
  4560. else if(event.button.x>=540 && event.button.x<=568 && event.button.y>=360 && event.button.y<=378 && event.button.button == SDL_BUTTON_LEFT && comptV2 > 0)
  4561. {
  4562. comptV2--;
  4563. break;
  4564. }
  4565. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=360 && event.button.y<=378 && event.button.button == SDL_BUTTON_LEFT && comptV2 < 1)
  4566. {
  4567. comptV2++;
  4568. break;
  4569. }
  4570. else if(event.button.x>=540 && event.button.x<=568 && event.button.y>=390 && event.button.y<=408 && event.button.button == SDL_BUTTON_LEFT && comptB2 > 0)
  4571. {
  4572. comptB2--;
  4573. break;
  4574. }
  4575. else if(event.button.x>=600 && event.button.x<=628 && event.button.y>=390 && event.button.y<=408 && event.button.button == SDL_BUTTON_LEFT && comptB2 < 1)
  4576. {
  4577. comptB2++;
  4578. break;
  4579. }
  4580. else
  4581. {
  4582. break;
  4583. }
  4584. }
  4585.  
  4586. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  4587. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  4588. SDL_BlitSurface(touchePre1, NULL, ecran, &positionPre1);
  4589. SDL_BlitSurface(toucheSui1, NULL, ecran, &positionSui1);
  4590. SDL_BlitSurface(touchePre2, NULL, ecran, &positionPre2);
  4591. SDL_BlitSurface(toucheSui2, NULL, ecran, &positionSui2);
  4592. SDL_BlitSurface(touchePre3, NULL, ecran, &positionPre3);
  4593. SDL_BlitSurface(toucheSui3, NULL, ecran, &positionSui3);
  4594. SDL_BlitSurface(touchePre4, NULL, ecran, &positionPre4);
  4595. SDL_BlitSurface(toucheSui4, NULL, ecran, &positionSui4);
  4596. SDL_BlitSurface(touchePre5, NULL, ecran, &positionPre5);
  4597. SDL_BlitSurface(toucheSui5, NULL, ecran, &positionSui5);
  4598. SDL_BlitSurface(touchePre6, NULL, ecran, &positionPre6);
  4599. SDL_BlitSurface(toucheSui6, NULL, ecran, &positionSui6);
  4600. SDL_BlitSurface(carreRouge1, NULL, ecran, &posCarreRouge1);
  4601. SDL_BlitSurface(carreVert1, NULL, ecran, &posCarreVert1);
  4602. SDL_BlitSurface(carreBleu1, NULL, ecran, &posCarreBleu1);
  4603. SDL_BlitSurface(carreRouge2, NULL, ecran, &posCarreRouge2);
  4604. SDL_BlitSurface(carreVert2, NULL, ecran, &posCarreVert2);
  4605. SDL_BlitSurface(carreBleu2, NULL, ecran, &posCarreBleu2);
  4606.  
  4607. if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  4608. {
  4609. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4610. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4611. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  4612. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  4613. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4614. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4615. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4616. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4617. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4618. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4619. }
  4620.  
  4621. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  4622. {
  4623. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4624. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4625. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  4626. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  4627. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4628. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4629. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4630. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4631. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4632. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4633. }
  4634.  
  4635. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  4636. {
  4637. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4638. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4639. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  4640. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  4641. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4642. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4643. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4644. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4645. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4646. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4647. }
  4648.  
  4649. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  4650. {
  4651. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4652. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4653. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  4654. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  4655. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4656. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4657. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4658. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4659. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4660. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4661. }
  4662.  
  4663. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  4664. {
  4665. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4666. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4667. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  4668. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  4669. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4670. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4671. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4672. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4673. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4674. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4675. }
  4676.  
  4677. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  4678. {
  4679. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4680. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4681. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  4682. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  4683. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4684. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4685. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4686. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4687. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4688. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4689. }
  4690.  
  4691. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  4692. {
  4693. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4694. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4695. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  4696. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  4697. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4698. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4699. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4700. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4701. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4702. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4703. }
  4704.  
  4705. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  4706. {
  4707. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  4708. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  4709. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  4710. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  4711. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4712. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4713. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4714. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4715. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4716. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4717. }
  4718.  
  4719. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  4720. {
  4721. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4722. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4723. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  4724. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  4725. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4726. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4727. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4728. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4729. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4730. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4731. }
  4732.  
  4733. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  4734. {
  4735. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4736. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4737. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  4738. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  4739. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4740. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4741. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4742. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4743. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4744. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4745. }
  4746.  
  4747. else if (comptR1 == 1 && comptV1 == 1 && comptB1 ==1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  4748. {
  4749. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4750. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4751. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  4752. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  4753. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4754. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4755. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4756. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4757. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4758. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4759. }
  4760.  
  4761. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  4762. {
  4763. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4764. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4765. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  4766. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  4767. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4768. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4769. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4770. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4771. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4772. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4773. }
  4774.  
  4775. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  4776. {
  4777. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4778. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4779. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  4780. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  4781. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4782. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4783. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4784. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4785. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4786. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4787. }
  4788.  
  4789. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  4790. {
  4791. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4792. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4793. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  4794. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  4795. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4796. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4797. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4798. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4799. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4800. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4801. }
  4802.  
  4803. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  4804. {
  4805. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4806. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4807. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  4808. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  4809. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4810. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4811. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  4812. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4813. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4814. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4815. }
  4816.  
  4817. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  4818. {
  4819. SDL_BlitSurface(pieceOff1B, NULL, ecran, &posPieceOff1B);
  4820. SDL_BlitSurface(pieceDef1B, NULL, ecran, &posPieceDef1B);
  4821. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  4822. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  4823. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4824. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4825. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4826. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4827. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4828. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4829. }
  4830.  
  4831. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  4832. {
  4833. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4834. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4835. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  4836. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  4837. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4838. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4839. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4840. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4841. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4842. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4843. }
  4844.  
  4845. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  4846. {
  4847. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4848. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4849. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  4850. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  4851. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4852. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4853. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4854. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4855. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4856. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4857. }
  4858.  
  4859. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  4860. {
  4861. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4862. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4863. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  4864. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  4865. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4866. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4867. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4868. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4869. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4870. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4871. }
  4872.  
  4873. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  4874. {
  4875. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4876. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4877. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  4878. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  4879. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4880. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4881. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4882. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4883. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4884. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4885. }
  4886.  
  4887. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  4888. {
  4889. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4890. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4891. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  4892. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  4893. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4894. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4895. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4896. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4897. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4898. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4899. }
  4900.  
  4901. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  4902. {
  4903. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4904. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4905. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  4906. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  4907. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4908. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4909. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4910. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4911. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4912. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4913. }
  4914.  
  4915. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  4916. {
  4917. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4918. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4919. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  4920. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  4921. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4922. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4923. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4924. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4925. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4926. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4927. }
  4928.  
  4929. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  4930. {
  4931. SDL_BlitSurface(pieceOff1R, NULL, ecran, &posPieceOff1R);
  4932. SDL_BlitSurface(pieceDef1R, NULL, ecran, &posPieceDef1R);
  4933. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  4934. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  4935. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  4936. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  4937. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4938. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4939. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4940. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4941. }
  4942.  
  4943. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  4944. {
  4945. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  4946. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  4947. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  4948. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  4949. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4950. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4951. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4952. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4953. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4954. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4955. }
  4956.  
  4957. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  4958. {
  4959. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  4960. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  4961. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  4962. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  4963. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4964. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4965. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4966. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4967. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4968. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  4969. }
  4970.  
  4971. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  4972. {
  4973. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  4974. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  4975. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  4976. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  4977. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4978. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4979. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4980. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  4981. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  4982. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4983. }
  4984.  
  4985. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  4986. {
  4987. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  4988. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  4989. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  4990. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  4991. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  4992. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  4993. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  4994. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  4995. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  4996. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  4997. }
  4998.  
  4999. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  5000. {
  5001. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  5002. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  5003. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  5004. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  5005. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5006. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5007. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5008. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5009. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5010. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5011. }
  5012.  
  5013. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  5014. {
  5015. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  5016. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  5017. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  5018. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  5019. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5020. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5021. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5022. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5023. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5024. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5025. }
  5026.  
  5027. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  5028. {
  5029. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  5030. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  5031. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  5032. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  5033. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5034. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5035. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5036. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5037. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5038. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5039. }
  5040.  
  5041. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  5042. {
  5043. SDL_BlitSurface(pieceOff1V, NULL, ecran, &posPieceOff1V);
  5044. SDL_BlitSurface(pieceDef1V, NULL, ecran, &posPieceDef1V);
  5045. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  5046. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  5047. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5048. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5049. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5050. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5051. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5052. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5053. }
  5054.  
  5055. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  5056. {
  5057. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5058. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5059. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  5060. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  5061. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5062. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5063. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5064. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5065. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5066. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5067. }
  5068.  
  5069. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  5070. {
  5071. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5072. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5073. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  5074. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  5075. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5076. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5077. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5078. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5079. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5080. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5081. }
  5082.  
  5083. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  5084. {
  5085. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5086. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5087. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  5088. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  5089. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5090. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5091. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5092. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5093. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5094. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5095. }
  5096.  
  5097. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  5098. {
  5099. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5100. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5101. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  5102. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  5103. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5104. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5105. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5106. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5107. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5108. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5109. }
  5110.  
  5111. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  5112. {
  5113. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5114. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5115. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  5116. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  5117. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5118. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5119. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5120. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5121. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5122. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5123. }
  5124.  
  5125. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  5126. {
  5127. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5128. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5129. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  5130. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  5131. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5132. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5133. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5134. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5135. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5136. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5137. }
  5138.  
  5139. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  5140. {
  5141. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5142. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5143. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  5144. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  5145. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5146. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5147. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5148. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5149. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5150. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5151. }
  5152.  
  5153. else if (comptR1 == 0 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  5154. {
  5155. SDL_BlitSurface(pieceOff1Bl, NULL, ecran, &posPieceOff1Bl);
  5156. SDL_BlitSurface(pieceDef1Bl, NULL, ecran, &posPieceDef1Bl);
  5157. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  5158. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  5159. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5160. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5161. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5162. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5163. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5164. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5165. }
  5166.  
  5167. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  5168. {
  5169. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5170. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5171. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  5172. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  5173. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5174. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5175. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5176. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5177. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5178. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5179. }
  5180.  
  5181. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  5182. {
  5183. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5184. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5185. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  5186. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  5187. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5188. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5189. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5190. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5191. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5192. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5193. }
  5194.  
  5195. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  5196. {
  5197. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5198. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5199. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  5200. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  5201. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5202. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5203. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5204. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5205. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5206. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5207. }
  5208.  
  5209. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  5210. {
  5211. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5212. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5213. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  5214. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  5215. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5216. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5217. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5218. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5219. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5220. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5221. }
  5222.  
  5223. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  5224. {
  5225. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5226. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5227. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  5228. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  5229. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5230. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5231. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5232. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5233. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5234. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5235. }
  5236.  
  5237. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  5238. {
  5239. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5240. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5241. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  5242. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  5243. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5244. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5245. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5246. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5247. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5248. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5249. }
  5250.  
  5251. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  5252. {
  5253. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5254. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5255. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  5256. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  5257. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5258. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5259. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5260. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5261. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5262. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5263. }
  5264.  
  5265. else if (comptR1 == 1 && comptV1 == 1 && comptB1 == 0 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  5266. {
  5267. SDL_BlitSurface(pieceOff1J, NULL, ecran, &posPieceOff1J);
  5268. SDL_BlitSurface(pieceDef1J, NULL, ecran, &posPieceDef1J);
  5269. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  5270. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  5271. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5272. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5273. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5274. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5275. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5276. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5277. }
  5278.  
  5279. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  5280. {
  5281. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5282. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5283. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  5284. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  5285. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5286. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5287. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5288. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5289. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5290. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5291. }
  5292.  
  5293. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  5294. {
  5295. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5296. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5297. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  5298. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  5299. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5300. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5301. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5302. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5303. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5304. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5305. }
  5306.  
  5307. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  5308. {
  5309. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5310. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5311. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  5312. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  5313. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5314. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5315. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5316. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5317. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5318. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5319. }
  5320.  
  5321. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  5322. {
  5323. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5324. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5325. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  5326. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  5327. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5328. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5329. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5330. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5331. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5332. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5333. }
  5334.  
  5335. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  5336. {
  5337. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5338. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5339. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  5340. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  5341. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5342. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5343. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5344. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5345. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5346. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5347. }
  5348.  
  5349. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  5350. {
  5351. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5352. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5353. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  5354. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  5355. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5356. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5357. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5358. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5359. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5360. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5361. }
  5362.  
  5363. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  5364. {
  5365. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5366. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5367. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  5368. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  5369. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5370. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5371. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5372. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5373. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5374. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5375. }
  5376.  
  5377. else if (comptR1 == 0 && comptV1 == 1 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  5378. {
  5379. SDL_BlitSurface(pieceOff1C, NULL, ecran, &posPieceOff1C);
  5380. SDL_BlitSurface(pieceDef1C, NULL, ecran, &posPieceDef1C);
  5381. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  5382. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  5383. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5384. SDL_BlitSurface(vert1, NULL, ecran, &posVert1A);
  5385. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5386. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5387. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5388. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5389. }
  5390.  
  5391. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 0)
  5392. {
  5393. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5394. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5395. SDL_BlitSurface(pieceOff2N, NULL, ecran, &posPieceOff2N);
  5396. SDL_BlitSurface(pieceDef2N, NULL, ecran, &posPieceDef2N);
  5397. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5398. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5399. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5400. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5401. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5402. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5403. }
  5404.  
  5405. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 1)
  5406. {
  5407. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5408. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5409. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  5410. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  5411. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5412. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5413. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5414. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5415. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5416. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5417. }
  5418.  
  5419. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 0)
  5420. {
  5421. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5422. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5423. SDL_BlitSurface(pieceOff2R, NULL, ecran, &posPieceOff2R);
  5424. SDL_BlitSurface(pieceDef2R, NULL, ecran, &posPieceDef2R);
  5425. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5426. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5427. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5428. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5429. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5430. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5431. }
  5432.  
  5433. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 0)
  5434. {
  5435. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5436. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5437. SDL_BlitSurface(pieceOff2V, NULL, ecran, &posPieceOff2V);
  5438. SDL_BlitSurface(pieceDef2V, NULL, ecran, &posPieceDef2V);
  5439. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5440. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5441. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5442. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5443. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5444. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5445. }
  5446.  
  5447. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 0 && comptB2 == 1)
  5448. {
  5449. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5450. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5451. SDL_BlitSurface(pieceOff2Bl, NULL, ecran, &posPieceOff2Bl);
  5452. SDL_BlitSurface(pieceDef2Bl, NULL, ecran, &posPieceDef2Bl);
  5453. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5454. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5455. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5456. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5457. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5458. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5459. }
  5460.  
  5461. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 1 && comptB2 == 0)
  5462. {
  5463. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5464. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5465. SDL_BlitSurface(pieceOff2J, NULL, ecran, &posPieceOff2J);
  5466. SDL_BlitSurface(pieceDef2J, NULL, ecran, &posPieceDef2J);
  5467. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5468. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5469. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5470. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5471. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5472. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0B);
  5473. }
  5474.  
  5475. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 0 && comptV2 == 1 && comptB2 == 1)
  5476. {
  5477. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5478. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5479. SDL_BlitSurface(pieceOff2C, NULL, ecran, &posPieceOff2C);
  5480. SDL_BlitSurface(pieceDef2C, NULL, ecran, &posPieceDef2C);
  5481. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5482. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5483. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5484. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0B);
  5485. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5486. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5487. }
  5488.  
  5489. else if (comptR1 == 1 && comptV1 == 0 && comptB1 == 1 && comptR2 == 1 && comptV2 == 0 && comptB2 == 1)
  5490. {
  5491. SDL_BlitSurface(pieceOff1M, NULL, ecran, &posPieceOff1M);
  5492. SDL_BlitSurface(pieceDef1M, NULL, ecran, &posPieceDef1M);
  5493. SDL_BlitSurface(pieceOff2M, NULL, ecran, &posPieceOff2M);
  5494. SDL_BlitSurface(pieceDef2M, NULL, ecran, &posPieceDef2M);
  5495. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1A);
  5496. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5497. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1A);
  5498. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5499. SDL_BlitSurface(vert0, NULL, ecran, &posVert0B);
  5500. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5501. }
  5502.  
  5503. else
  5504. {
  5505. SDL_BlitSurface(pieceOff1N, NULL, ecran, &posPieceOff1N);
  5506. SDL_BlitSurface(pieceDef1N, NULL, ecran, &posPieceDef1N);
  5507. SDL_BlitSurface(pieceOff2B, NULL, ecran, &posPieceOff2B);
  5508. SDL_BlitSurface(pieceDef2B, NULL, ecran, &posPieceDef2B);
  5509. SDL_BlitSurface(rouge0, NULL, ecran, &posRouge0A);
  5510. SDL_BlitSurface(vert0, NULL, ecran, &posVert0A);
  5511. SDL_BlitSurface(bleu0, NULL, ecran, &posBleu0A);
  5512. SDL_BlitSurface(rouge1, NULL, ecran, &posRouge1B);
  5513. SDL_BlitSurface(vert1, NULL, ecran, &posVert1B);
  5514. SDL_BlitSurface(bleu1, NULL, ecran, &posBleu1B);
  5515. }
  5516. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5517. }
  5518.  
  5519. //Option - reglage du fond d'écran
  5520. else if(posSelectMenu.y >=250 && (posSelectMenu.y <300))
  5521. {
  5522. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  5523. switch(event.type) /* On teste le type d'évènement */
  5524. {
  5525. case SDL_KEYDOWN:
  5526. switch(event.key.keysym.sym)
  5527. {
  5528. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  5529. continuer2 = 0;
  5530. break;
  5531.  
  5532. case SDLK_LEFT:
  5533. if (compteurFond > 0)
  5534. {
  5535. compteurFond--;
  5536. break;
  5537. }
  5538. break;
  5539.  
  5540. case SDLK_RIGHT:
  5541. if(compteurFond <= 3)
  5542. {
  5543. compteurFond++;
  5544. break;
  5545. }
  5546. default:
  5547. break;
  5548.  
  5549. }
  5550. break;
  5551.  
  5552. case SDL_MOUSEBUTTONUP:
  5553. if(event.button.x>=ecran->w / 2 - touchePre7->w / 2 - 20 && event.button.x<=ecran->w / 2 - touchePre7->w / 2 - 2 && event.button.y>=480 && event.button.y<=508 && event.button.button == SDL_BUTTON_LEFT && compteurFond > 0)
  5554. {
  5555. compteurFond--;
  5556. }
  5557. else if(event.button.x>=ecran->w / 2 - touchePre7->w / 2 + 20 && event.button.x<=ecran->w / 2 - touchePre7->w / 2 + 38 && event.button.y>=480 && event.button.y<=508 && event.button.button == SDL_BUTTON_LEFT && compteurFond <= 3)
  5558. {
  5559. compteurFond++;;
  5560. break;
  5561. }
  5562.  
  5563. else
  5564. {
  5565. break;
  5566. }
  5567. }
  5568.  
  5569. if (compteurFond == 0)
  5570. {
  5571. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5572. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5573. SDL_BlitSurface(textureDamFond, NULL, ecran, &positionDamFond); /* On blitte par-dessus l'écran */
  5574.  
  5575. }
  5576. else if (compteurFond == 1)
  5577. {
  5578. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5579. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5580. SDL_BlitSurface(textureEtoile2, NULL, ecran, &positionEtoile2); /* On blitte par-dessus l'écran */
  5581.  
  5582. }
  5583. else if (compteurFond == 2)
  5584. {
  5585. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5586. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5587. SDL_BlitSurface(textureForet2, NULL, ecran, &positionForet2); /* On blitte par-dessus l'écran */
  5588.  
  5589. }
  5590. else if (compteurFond == 3)
  5591. {
  5592. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5593. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5594. SDL_BlitSurface(texturePlage2, NULL, ecran, &positionPlage2); /* On blitte par-dessus l'écran */
  5595.  
  5596.  
  5597. }
  5598. else
  5599. {
  5600. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5601. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5602. SDL_BlitSurface(textureNuit2, NULL, ecran, &positionNuit2); /* On blitte par-dessus l'écran */
  5603. }
  5604. SDL_BlitSurface(damierInc400400NB, NULL, ecran, &posDamInc400400VB);
  5605. SDL_BlitSurface(touchePre7, NULL, ecran, &positionPre7);
  5606. SDL_BlitSurface(toucheSui7, NULL, ecran, &positionSui7);
  5607. SDL_BlitSurface(txtTexture, NULL, ecran, &posTxtTexture);
  5608. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5609. //freesurface ici
  5610.  
  5611. }
  5612.  
  5613. //Option - reglage du volume
  5614. else
  5615. {
  5616. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  5617. switch(event.type) /* On teste le type d'évènement */
  5618. {
  5619. case SDL_KEYDOWN:
  5620. switch(event.key.keysym.sym)
  5621. {
  5622. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  5623. continuer2 = 0;
  5624. break;
  5625.  
  5626. case SDLK_LEFT: // Flèche gauche
  5627. if(posBoutonVol.x >=400)
  5628. {
  5629. posBoutonVol.x = posBoutonVol.x - 77;
  5630. break;
  5631. }
  5632. break;
  5633.  
  5634. case SDLK_RIGHT: // Flèche droite
  5635. if(posBoutonVol.x <=600)
  5636. {
  5637. posBoutonVol.x = posBoutonVol.x + 77;
  5638. break;
  5639. }
  5640. default:
  5641. break;
  5642. }
  5643. break;
  5644.  
  5645. case SDL_MOUSEBUTTONUP:
  5646. if(event.button.x>=590 && event.button.x<=608 && event.button.y>=230 && event.button.y<=258 && event.button.button == SDL_BUTTON_LEFT && posBoutonVol.x >= 230)
  5647. {
  5648. posBoutonVol.x = posBoutonVol.x - 77;
  5649. break;
  5650. }
  5651. else if(event.button.x>=640 && event.button.x<=658 && event.button.y>=230 && event.button.y<=258 && event.button.button == SDL_BUTTON_LEFT && posBoutonVol.x <= 450)
  5652. {
  5653. posBoutonVol.x = posBoutonVol.x + 77;
  5654. break;
  5655. }
  5656. else
  5657. {
  5658. break;
  5659. }
  5660. break;
  5661. }
  5662.  
  5663. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran*/
  5664. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5665. SDL_BlitSurface(txtRegDuVol, NULL, ecran, &posTxtReglageV);
  5666. SDL_BlitSurface(reglageVol, NULL, ecran, &positionReglageV);
  5667. SDL_BlitSurface(selectVolume, NULL, ecran, &posSelectVol);
  5668. SDL_BlitSurface(selectBoutonVol, NULL, ecran, &posBoutonVol);
  5669. SDL_BlitSurface(touchePre7, NULL, ecran, &positionPre7);
  5670. SDL_BlitSurface(toucheSui7, NULL, ecran, &positionSui7);
  5671. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5672. }
  5673. }
  5674. default:
  5675. break;
  5676. }
  5677. }
  5678. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  5679. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5680. SDL_BlitSurface(selectMenu, NULL, ecran, &posSelectMenu);/* On blitte par-dessus l'écran */
  5681. SDL_BlitSurface(ssMenu5, NULL, ecran, &positionSsMenu5); /* Blit du texte option par-dessus */
  5682. SDL_BlitSurface(textureDamier, NULL, ecran, &positionTextureD); /* Blit du texte menu4 par-dessus */
  5683. SDL_BlitSurface(textureDeFond, NULL, ecran, &positionTextureF); /* Blit du texte menu5 par-dessus */
  5684. SDL_BlitSurface(reglageVol, NULL, ecran, &positionReglageV); /* Blit du texte menu6 par-dessus */
  5685. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5686. continuer2 = 1;
  5687. }
  5688. }
  5689.  
  5690.  
  5691. //quand le pointeur est sur le menu Règle du jeu
  5692. else if(posSelectMenu.y >=450 && posSelectMenu.y<500)
  5693. {
  5694. while (continuer1) /* TANT QUE la variable ne vaut pas 0 */
  5695. {
  5696. SDL_WaitEvent(&event); /* On attend un évènement qu'on récupère dans event */
  5697. switch(event.type) /* On teste le type d'évènement */
  5698. {
  5699. case SDL_QUIT: /* Si c'est un évènement QUITTER */
  5700. continuer = 0; /* On met le booléen à 0, donc la boucle va s'arrêter */
  5701. break;
  5702.  
  5703. case SDL_KEYDOWN:
  5704. switch (event.key.keysym.sym)
  5705. {
  5706. case SDLK_ESCAPE: /* Appui sur la touche Echap, on arrête le programme */
  5707. continuer1 = 0;
  5708. break;
  5709.  
  5710. case SDLK_LEFT:
  5711. if (compteurRegle > 0)
  5712. {
  5713. compteurRegle--;
  5714. break;
  5715. }
  5716. break;
  5717.  
  5718. case SDLK_RIGHT:
  5719. if(compteurRegle <= 5)
  5720. {
  5721. compteurRegle++;
  5722. break;
  5723. }
  5724. default:
  5725. break;
  5726. }
  5727.  
  5728. case SDL_MOUSEBUTTONUP:
  5729. if(event.button.x>=ecran->w / 2 - touchePre7->w / 2 - 20 && event.button.x<=ecran->w / 2 - touchePre7->w / 2 - 2 && event.button.y>=480 && event.button.y<=508 && event.button.button == SDL_BUTTON_LEFT && compteurRegle > 0)
  5730. {
  5731. compteurRegle--;
  5732. break;
  5733. }
  5734. else if(event.button.x>=ecran->w / 2 - touchePre7->w / 2 + 20 && event.button.x<=ecran->w / 2 - touchePre7->w / 2 + 38 && event.button.y>=480 && event.button.y<=508 && event.button.button == SDL_BUTTON_LEFT && compteurRegle <= 5)
  5735. {
  5736. compteurRegle++;
  5737. break;
  5738. }
  5739. else
  5740. {
  5741. break;
  5742. }
  5743. break;
  5744. }
  5745.  
  5746. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  5747. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5748. SDL_BlitSurface(ssMenu6, NULL, ecran, &positionSsMenu6);
  5749. if(compteurRegle == 1)
  5750. {
  5751. SDL_BlitSurface(regleJeu2, NULL, ecran, &posRegleJeu2);
  5752. }
  5753. else if(compteurRegle == 2)
  5754. {
  5755. SDL_BlitSurface(regleJeu3, NULL, ecran, &posRegleJeu3);
  5756. }
  5757. else if(compteurRegle == 3)
  5758. {
  5759. SDL_BlitSurface(regleJeu4, NULL, ecran, &posRegleJeu4);
  5760. }
  5761. else if(compteurRegle == 4)
  5762. {
  5763. SDL_BlitSurface(regleJeu5, NULL, ecran, &posRegleJeu5);
  5764. }
  5765. else if(compteurRegle == 5)
  5766. {
  5767. SDL_BlitSurface(regleJeu6, NULL, ecran, &posRegleJeu6);
  5768. }
  5769. else if(compteurRegle == 6)
  5770. {
  5771. SDL_BlitSurface(regleJeu7, NULL, ecran, &posRegleJeu7);
  5772. }
  5773. else
  5774. {
  5775. SDL_BlitSurface(regleJeu1, NULL, ecran, &posRegleJeu1);
  5776. }
  5777. SDL_BlitSurface(touchePre7, NULL, ecran, &positionPre7);
  5778. SDL_BlitSurface(toucheSui7, NULL, ecran, &positionSui7);
  5779. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5780. continuer2 = 1;
  5781. }
  5782. }
  5783.  
  5784. //quand le pointeur est sur le menu exit
  5785. else
  5786. {
  5787. continuer = 0;
  5788. break;
  5789. }
  5790. break;
  5791. }
  5792. }
  5793. break;
  5794.  
  5795. }
  5796. SDL_FillRect(ecran, NULL, SDL_MapRGB(ecran->format, 255, 255, 255)); /* On efface l'écran */
  5797. SDL_BlitSurface(textureFond, NULL, ecran, &positionFond); /* On blitte par-dessus l'écran */
  5798. SDL_BlitSurface(selectMenu, NULL, ecran, &posSelectMenu);/* On blitte par-dessus l'écran */
  5799. SDL_BlitSurface(menu, NULL, ecran, &positionMenu); /* Blit du texte menu par-dessus */
  5800. SDL_BlitSurface(menu1, NULL, ecran, &positionMenu1); /* Blit du texte menu1 par-dessus */
  5801. SDL_BlitSurface(menu2, NULL, ecran, &positionMenu2); /* Blit du texte menu2 par-dessus */
  5802. SDL_BlitSurface(menu3, NULL, ecran, &positionMenu3); /* Blit du texte menu3 par-dessus */
  5803. SDL_BlitSurface(menu4, NULL, ecran, &positionMenu4); /* Blit du texte menu4 par-dessus */
  5804. SDL_BlitSurface(menu5, NULL, ecran, &positionMenu5); /* Blit du texte menu5 par-dessus */
  5805. SDL_BlitSurface(menu6, NULL, ecran, &positionMenu6); /* Blit du texte menu6 par-dessus */
  5806. SDL_BlitSurface(menu7, NULL, ecran, &positionMenu7); /* Blit du texte menu6 par-dessus */
  5807. SDL_Flip(ecran); /* Mise à jour de l'écran avec sa nouvelle couleur */
  5808. continuer1 = 1;
  5809. }
  5810.  
  5811. TTF_CloseFont(police);
  5812. TTF_Quit();
  5813.  
  5814. /* On libère les surfaces */
  5815. SDL_FreeSurface(txtDeplaNA);
  5816.  
  5817. SDL_FreeSurface(menu);
  5818.  
  5819. SDL_FreeSurface(ecran);
  5820. SDL_FreeSurface(CubikRed);
  5821. SDL_FreeSurface(CubikBlue);
  5822. SDL_FreeSurface(textureFond);
  5823. SDL_FreeSurface(textureEtoile);
  5824. SDL_FreeSurface(textureForet);
  5825. SDL_FreeSurface(texturePlage);
  5826. SDL_FreeSurface(textureNuit);
  5827. SDL_FreeSurface(textJ1Commence);
  5828. SDL_FreeSurface(damierInc800800NB);
  5829. SDL_FreeSurface(pieceJeuOff1N);
  5830. SDL_FreeSurface(pieceJeuDef1N);
  5831. SDL_FreeSurface(pieceJeuOff2N);
  5832. SDL_FreeSurface(pieceJeuDef2N);
  5833.  
  5834. SDL_FreeSurface(menu2);
  5835. SDL_FreeSurface(ssMenu2);
  5836.  
  5837. SDL_FreeSurface(menu3);
  5838. SDL_FreeSurface(ssMenu3);
  5839.  
  5840. SDL_FreeSurface(menu4);
  5841. SDL_FreeSurface(ssMenu4);
  5842. SDL_FreeSurface(texteSelect);
  5843.  
  5844. SDL_FreeSurface(menu5);
  5845. SDL_FreeSurface(ssMenu5);
  5846. SDL_FreeSurface(textureDeFond); //il s'agit d'un texte du sous menu 5
  5847. SDL_FreeSurface(textureDamier);
  5848. SDL_FreeSurface(textureDamFond);
  5849. SDL_FreeSurface(txtTexture);
  5850. SDL_FreeSurface(textureFond);
  5851. SDL_FreeSurface(textureEtoile2);
  5852. SDL_FreeSurface(textureNuit2);
  5853. SDL_FreeSurface(texturePlage2);
  5854. SDL_FreeSurface(textureForet2);
  5855. SDL_FreeSurface(reglageVol);
  5856. SDL_FreeSurface(ssMenu1);
  5857. SDL_FreeSurface(pieceOff1N);
  5858. SDL_FreeSurface(pieceDef1N);
  5859. SDL_FreeSurface(pieceOff2N);
  5860. SDL_FreeSurface(pieceDef2N);
  5861. SDL_FreeSurface(pieceOff1B);
  5862. SDL_FreeSurface(pieceDef1B);
  5863. SDL_FreeSurface(pieceOff2B);
  5864. SDL_FreeSurface(pieceDef2B);
  5865. SDL_FreeSurface(pieceOff1R);
  5866. SDL_FreeSurface(pieceDef1R);
  5867. SDL_FreeSurface(pieceOff2R);
  5868. SDL_FreeSurface(pieceDef2R);
  5869. SDL_FreeSurface(pieceOff1V);
  5870. SDL_FreeSurface(pieceDef1V);
  5871. SDL_FreeSurface(pieceOff2V);
  5872. SDL_FreeSurface(pieceDef2V);
  5873. SDL_FreeSurface(pieceOff1Bl);
  5874. SDL_FreeSurface(pieceDef1Bl);
  5875. SDL_FreeSurface(pieceOff2Bl);
  5876. SDL_FreeSurface(pieceDef2Bl);
  5877. SDL_FreeSurface(pieceOff1J);
  5878. SDL_FreeSurface(pieceDef1J);
  5879. SDL_FreeSurface(pieceOff2J);
  5880. SDL_FreeSurface(pieceDef2J);
  5881. SDL_FreeSurface(pieceOff1C);
  5882. SDL_FreeSurface(pieceDef1C);
  5883. SDL_FreeSurface(pieceOff2C);
  5884. SDL_FreeSurface(pieceDef2C);
  5885. SDL_FreeSurface(pieceOff1M);
  5886. SDL_FreeSurface(pieceDef1M);
  5887. SDL_FreeSurface(pieceOff2M);
  5888. SDL_FreeSurface(pieceDef2M);
  5889. SDL_FreeSurface(touchePre1);
  5890. SDL_FreeSurface(toucheSui1);
  5891. SDL_FreeSurface(touchePre2);
  5892. SDL_FreeSurface(toucheSui2);
  5893. SDL_FreeSurface(touchePre3);
  5894. SDL_FreeSurface(toucheSui3);
  5895. SDL_FreeSurface(touchePre4);
  5896. SDL_FreeSurface(toucheSui4);
  5897. SDL_FreeSurface(touchePre5);
  5898. SDL_FreeSurface(toucheSui5);
  5899. SDL_FreeSurface(touchePre6);
  5900. SDL_FreeSurface(toucheSui6);
  5901. SDL_FreeSurface(touchePre7);
  5902. SDL_FreeSurface(toucheSui7);
  5903. SDL_FreeSurface(carreRouge1);
  5904. SDL_FreeSurface(carreVert1);
  5905. SDL_FreeSurface(carreBleu1);
  5906. SDL_FreeSurface(carreRouge2);
  5907. SDL_FreeSurface(carreVert2);
  5908. SDL_FreeSurface(carreBleu2);
  5909. SDL_FreeSurface(rouge1);
  5910. SDL_FreeSurface(vert1);
  5911. SDL_FreeSurface(bleu1);
  5912. SDL_FreeSurface(rouge0);
  5913. SDL_FreeSurface(vert0);
  5914. SDL_FreeSurface(bleu0);
  5915. SDL_FreeSurface(selectVolume);
  5916. SDL_FreeSurface(selectBoutonVol);
  5917. SDL_FreeSurface(txtRegDuVol);
  5918. SDL_FreeSurface(damierInc400400NB);
  5919.  
  5920. SDL_FreeSurface(menu6);
  5921. SDL_FreeSurface(ssMenu6);
  5922. SDL_FreeSurface(carreBlanc);
  5923. SDL_FreeSurface(regleJeu1);
  5924. SDL_FreeSurface(regleJeu2);
  5925. SDL_FreeSurface(regleJeu3);
  5926. SDL_FreeSurface(regleJeu4);
  5927. SDL_FreeSurface(regleJeu5);
  5928. SDL_FreeSurface(regleJeu6);
  5929. SDL_FreeSurface(regleJeu7);
  5930.  
  5931.  
  5932.  
  5933. SDL_FreeSurface(menu7);
  5934.  
  5935. SDL_FreeSurface(selectMenu);
  5936.  
  5937. SDL_Quit();
  5938.  
  5939. return EXIT_SUCCESS;
  5940. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement