Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 111.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <winbgim.h>
  4. #include <time.h>
  5. #include <math.h>
  6. #include <SFML/Audio.hpp>
  7. using namespace std;
  8.  
  9. #define LUNGIME 1632
  10. #define LATIME 960
  11. #define LATURA 96
  12.  
  13. #define JUCATOR1 1
  14. #define JUCATOR2 2
  15. #define POSIBIL 3
  16. #define CULOARE_POSIBIL LIGHTGREEN
  17.  
  18. #define MARGINE_V 108
  19. #define MARGINE_O 420
  20.  
  21. #define LEN 50
  22.  
  23. #define ZI 0
  24. #define NOAPTE 1
  25.  
  26. #define RO 0
  27. #define EN 1
  28.  
  29. #define PORNIT 0
  30. #define OPRIT 1
  31.  
  32. #define COORD1(x) x[limba][0], x[limba][1], x[limba][2], x[limba][3] // ast e pt imagini
  33. #define COORD2(x) x[0], x[1] // asta e pt text
  34. #define STERGE(x) x[limba][0], x[limba][1], x[limba][2]+1, x[limba][3]+1 // pt bar()
  35.  
  36. #define debug(x,y) cout<<x<<' '<<y<<'\n';
  37.  
  38. // locatii fisiere[mod][limba][2] + pozitii butoane[limba][4]
  39.  
  40. // butoane muzica+credits
  41. const char imgMuzica[2][2][LEN] = {"img/muzicaD1.jpg", "img/muzicaD2.jpg", "img/muzicaN1.jpg", "img/muzicaN2.jpg"};
  42. const char imgSfx[2][2][LEN] = {"img/sfxD1.jpg", "img/sfxD2.jpg", "img/sfxN1.jpg", "img/sfxN2.jpg"};
  43. const char imgCredit[2][2][LEN] = {"img/creditDRO.jpg", "img/creditDEN.jpg", "img/creditNRO.jpg", "img/creditNEN.jpg"};
  44. const char imgInfo[2][2][LEN] = {"img/infoDRO.jpg", "img/infoDEN.jpg", "img/infoNRO.jpg", "img/infoNEN.jpg"};
  45. const int pozMuzica[2][4] = {24, 24, 55, 55, 24, 24, 55, 55};
  46. const int pozSfx[2][4] = {80, 24, 111, 55, 80, 24, 111, 55};
  47. const int pozCredit[2][4] = {1512, 24, 1608, 48, 1512, 24, 1608, 48};
  48.  
  49. // setari meniu principal
  50. const char imgSoare[2][LEN] = {"img/soareD.jpg", "img/soareN.jpg"};
  51. const char imgLuna[2][LEN] = {"img/lunaD.jpg", "img/lunaN.jpg"};
  52. const char imgRo[2][2][LEN] = {"img/roN.jpg", "img/roD.jpg", "img/roD.jpg", "img/roN.jpg"};
  53. const char imgEn[2][2][LEN] = {"img/enD.jpg", "img/enN.jpg", "img/enN.jpg", "img/enD.jpg"};
  54. const int pozSoare[2][4] = {24, 816, 72, 864, 24, 816, 72, 864};
  55. const int pozLuna[2][4] = {24, 888, 72, 936, 24, 888, 72, 936};
  56. const int pozRo[2][4] = {1488, 888, 1536, 936, 1488, 888, 1536, 936};
  57. const int pozEn[2][4] = {1560, 888, 1608, 936, 1560, 888, 1608, 936};
  58.  
  59. // butoane meniu principal
  60. const char imgTitlu[2][2][LEN] = {"img/titluDRO.jpg", "img/titluDEN.jpg", "img/titluNRO.jpg", "img/titluNEN.jpg"};
  61. const char imgJocNou[2][2][LEN] = {"img/jocnouDRO.jpg", "img/jocnouDEN.jpg", "img/jocnouNRO.jpg", "img/jocnouNEN.jpg"};
  62. const char imgTutorial[2][2][LEN] = {"img/tutorialDRO.jpg", "img/tutorialDEN.jpg", "img/tutorialNRO.jpg", "img/tutorialNEN.jpg"};
  63. const char imgSetari[2][2][LEN] = {"img/setariDRO.jpg", "img/setariDEN.jpg", "img/setariNRO.jpg", "img/setariNEN.jpg"};
  64. const char imgIesire[2][2][LEN] = {"img/iesireDRO.jpg", "img/iesireDEN.jpg", "img/iesireNRO.jpg", "img/iesireNEN.jpg"};
  65. const int pozTitlu[2][4] = {288, 120, 1344, 216, 288, 120, 1344, 216};
  66. const int pozJocNou[2][4] = {672, 312, 960, 408, 648, 312, 984, 408};
  67. const int pozTutorial[2][4] = {600, 432, 1032, 528, 624, 432, 1008, 528};
  68. const int pozSetari[2][4] = {720, 552, 912, 648, 696, 552, 936, 648};
  69. const int pozIesire[2][4] = {696, 672, 936, 768, 744, 672, 888, 768};
  70.  
  71. // buton inapoi + butoane meniu Joc Nou
  72. const char imgInapoi[2][LEN] = {"img/inapoiD.jpg", "img/inapoiN.jpg"};
  73. const char imgPVP[2][2][LEN] = {"img/pvpDRO.jpg", "img/pvpDEN.jpg", "img/pvpNRO.jpg", "img/pvpNEN.jpg"};
  74. const char imgPVIA[2][2][LEN] = {"img/pviaDRO.jpg", "img/pviaDEN.jpg", "img/pviaNRO.jpg", "img/pviaNEN.jpg"};
  75. const char imgReluare[2][2][LEN] = {"img/reluareDRO.jpg", "img/reluareDEN.jpg", "img/reluareNRO.jpg", "img/reluareNEN.jpg"};
  76. const char imgOptiuni[2][2][LEN] = {"img/optiuniDRO.jpg", "img/optiuniDEN.jpg", "img/optiuniNRO.jpg", "img/optiuniNEN.jpg"};
  77. const int pozInapoi[2][4] = {1512, 24, 1608, 72, 1512, 24, 1608, 72};
  78. const int pozPVP[2][4] = {576, 288, 1056, 384, 600, 288, 1032, 384};
  79. const int pozPVIA[2][4] = {624, 408, 1008, 504, 648, 408, 984, 504};
  80. const int pozReluare[2][4] = {696, 528, 936, 624, 696, 528, 936, 624};
  81. const int pozOptiuni[2][4] = {72, 768, 1560, 811, 72, 768, 1560, 811};
  82.  
  83. // butoane <Selectie> Joc Nou
  84. const char imgSageataL[2][LEN] = {"img/sageatalD.jpg", "img/sageatalN.jpg"};
  85. const char imgSageataR[2][LEN] = {"img/sageatarD.jpg", "img/sageatarN.jpg"};
  86. const int pozS1[2] = {240, 840+10};
  87. const int pozS1a[2][4] = {216-72, 816, 264-72, 864, 216-72, 816, 264-72, 864};
  88. const int pozS1b[2][4] = {216+72, 816, 264+72, 864, 216+72, 816, 264+72, 864};
  89. const int pozS2[2] = {816, 840+10};
  90. const int pozS2a[2][4] = {792-72, 816, 840-72, 864, 792-72, 816, 840-72, 864};
  91. const int pozS2b[2][4] = {792+72, 816, 840+72, 864, 792+72, 816, 840+72, 864};
  92. const int pozS3[2] = {1392, 840+10};
  93. const int pozS3a[2][4] = {1368-72, 816, 1416-72, 864, 1368-72, 816, 1416-72, 864};
  94. const int pozS3b[2][4] = {1368+72, 816, 1416+72, 864, 1368+72, 816, 1416+72, 864};
  95.  
  96. // imagini In Joc + butoane informative/abandon
  97. const char imgTabla[2][3][LEN] = {"img/tabla1.jpg", "img/tabla2.jpg", "img/tabla3.jpg", "img/tabla1p.jpg", "img/tabla2p.jpg", "img/tabla3p.jpg"};
  98. const char imgPatrat[3][LEN] = {"img/patrat1.jpg", "img/patrat2.jpg","img/patrat3.jpg"};
  99. const char imgPiesaA[3][LEN] = {"img/piesaA1.gif", "img/piesaA2.gif", "img/piesaA3.gif"};
  100. const char imgPiesaB[3][LEN] = {"img/piesaB1.gif", "img/piesaB2.gif", "img/piesaB3.gif"};
  101. const char imgAbandon[2][2][LEN] = {"img/abandonDRO.jpg", "img/abandonDEN.jpg", "img/abandonNRO.jpg", "img/abandonNEN.jpg"};
  102. const int pozRand1[2] = {93, 364}, pozRand2[2] = {325, 599}, pozScor[2] = {210, 482};
  103. const int pozPiesaA[2][4] = {36, 384, 131, 479, 36, 384, 131, 479};
  104. const int pozPiesaB[2][4] = {288, 480, 383, 575, 288, 480, 383, 575};
  105. const int pozTabla[2][4] = {408, 96, 1200, 888, 408, 96, 1200, 888};
  106. const int pozIstoric[2][4] = {1248, 240, 1608, 822, 1248, 240, 1608, 822};
  107. const int pozRamase[2] = {203, 853}, pozTimer[2] = {1430, 163};
  108. const int pozAbandon[2][4] = {1368, 840, 1488, 864, 1368, 840, 1488, 864};
  109.  
  110. // butoane informative + meniu Sfarsit Joc
  111. const char imgIstoric[2][LEN] = {"img/istoricD.jpg", "img/istoricN.jpg"};
  112. const char imgEgal[2][2][LEN] = {"img/egalDRO.jpg", "img/egalDEN.jpg", "img/egalNRO.jpg", "img/egalNEN.jpg"};
  113. const char imgVictorie[2][2][LEN] = {"img/victorieDRO.jpg", "img/victorieDEN.jpg", "img/victorieNRO.jpg", "img/victorieNEN.jpg"};
  114. const char imgSfarsit[2][LEN] = {"img/sfarsitD.jpg", "img/sfarsitN.jpg"};
  115. const char imgRestart[2][LEN] = {"img/restartD.jpg", "img/restartN.jpg"};
  116. const char imgSalveaza[2][2][LEN] = {"img/salveazaDRO.jpg", "img/salveazaDEN.jpg", "img/salveazaNRO.jpg", "img/salveazaNEN.jpg"};
  117. const char imgSalvat[2][2][LEN] = {"img/salvatDRO.jpg", "img/salvatDEN.jpg", "img/salvatNRO.jpg", "img/salvatNEN.jpg"};
  118. const char imgLaMeniu[2][2][LEN] = {"img/lameniuDRO.jpg", "img/lameniuDEN.jpg", "img/lameniuNRO.jpg", "img/lameniuNEN.jpg"};
  119. const int pozRezultat[2][4] = {528, 216, 1104, 360, 528, 216, 1104, 360};
  120. const int pozSfarsit[2][4] = {528, 408, 1104, 744, 528, 408, 1104, 744};
  121. const int pozRestart[2][4] = {696, 432, 936, 528, 696, 432, 936, 528};
  122. const int pozSalveaza[2][4] = {576, 528, 1056, 624, 576, 528, 1056, 624};
  123. const int pozLaMeniu[2][4] = {576, 624, 1056, 720, 576+24, 624, 1056-24, 720};
  124.  
  125. // butoane Cum Se Joaca + imagini ghid
  126. const char imgTut1[2][2][LEN] = {"img/tut1DRO.jpg", "img/tut1DEN.jpg", "img/tut1NRO.jpg", "img/tut1NEN.jpg"};
  127. const char imgTut2[2][2][LEN] = {"img/tut2DRO.jpg", "img/tut2DEN.jpg", "img/tut2NRO.jpg", "img/tut2NEN.jpg"};
  128. const char imgTut3[2][2][LEN] = {"img/tut3DRO.jpg", "img/tut3DEN.jpg", "img/tut3NRO.jpg", "img/tut3NEN.jpg"};
  129. const char imgTut4[2][2][LEN] = {"img/tut4DRO.jpg", "img/tut4DEN.jpg", "img/tut4NRO.jpg", "img/tut4NEN.jpg"};
  130. const char imgTut5[2][2][LEN] = {"img/tut5DRO.jpg", "img/tut5DEN.jpg", "img/tut5NRO.jpg", "img/tut5NEN.jpg"};
  131. const char imgGhid1[2][2][LEN] = {"img/ghid1DRO.jpg", "img/ghid1DEN.jpg", "img/ghid1NRO.jpg", "img/ghid1NEN.jpg"};
  132. const char imgGhid2[2][2][LEN] = {"img/ghid2DRO.jpg", "img/ghid2DEN.jpg", "img/ghid2NRO.jpg", "img/ghid2NEN.jpg"};
  133. const char imgGhid3[2][2][LEN] = {"img/ghid3DRO.jpg", "img/ghid3DEN.jpg", "img/ghid3NRO.jpg", "img/ghid3NEN.jpg"};
  134. const char imgGhid4[2][2][LEN] = {"img/ghid4DRO.jpg", "img/ghid4DEN.jpg", "img/ghid4NRO.jpg", "img/ghid4NEN.jpg"};
  135. const char imgGhid5[2][2][LEN] = {"img/ghid5DRO.jpg", "img/ghid5DEN.jpg", "img/ghid5NRO.jpg", "img/ghid5NEN.jpg"};
  136. const int pozTut1[2][4] = {48, 168, 288, 264, 48, 168, 288, 264};
  137. const int pozTut2[2][4] = {96, 312, 360, 408, 96, 312, 360, 408};
  138. const int pozTut3[2][4] = {96, 456, 384, 552, 96, 456, 384, 552};
  139. const int pozTut4[2][4] = {96, 600, 432, 696, 96, 600, 432, 696};
  140. const int pozTut5[2][4] = {48, 744, 312, 840, 48, 744, 264, 840};
  141. const int pozGhid[2][4] = {576, 192, 1632, 768, 576, 192, 1632, 768};
  142.  
  143. // butoane <selectie> Aspect + text in Setari
  144. const char imgAspect[2][2][LEN] = {"img/aspectDRO.jpg", "img/aspectDEN.jpg", "img/aspectNRO.jpg", "img/aspectNEN.jpg"};
  145. const int pozAspect[2][4] = {48, 96, 1440, 600, 48, 96, 1440, 600};
  146. const int pozA1[2][4] = {240, 336, 335, 431, 240, 336, 335, 431};
  147. const int pozA1a[2][4] = {168, 336+24, 216, 432-24, 168, 336+24, 216, 432-24};
  148. const int pozA1b[2][4] = {360, 336+24, 408, 432-24, 360, 336+24, 408, 432-24};
  149. const int pozA2[2][4] = {240, 600, 335, 695, 240, 600, 335, 695};
  150. const int pozA2a[2][4] = {168, 600+24, 216, 696-24, 168, 600+24, 216, 696-24};
  151. const int pozA2b[2][4] = {360, 600+24, 408, 696-24, 360, 600+24, 408, 696-24};
  152. const int pozA3[2][4] = {768, 192, 1439, 863, 768, 192, 1439, 863};
  153. const int pozA3a[2][4] = {696, 504, 744, 552, 696, 504, 744, 552};
  154. const int pozA3b[2][4] = {1464, 504, 1512, 552, 1464, 504, 1512, 552};
  155. const int pozInfo[2][4] = {384, 192, 1248, 768, 384, 192, 1248, 768};
  156.  
  157. // iconite
  158. const char imgJoystick[2][LEN] = {"img/joystickD.jpg", "img/joystickN.jpg"};
  159. const char imgCarte[2][LEN] = {"img/carteD.jpg", "img/carteN.jpg"};
  160. const char imgRotita[2][LEN] = {"img/rotitaD.jpg", "img/rotitaN.jpg"};
  161. const char imgX[2][LEN] = {"img/xD.jpg", "img/xN.jpg"};
  162. const char imgOm[2][LEN] = {"img/omD.jpg", "img/omN.jpg"};
  163. const char imgOchi[2][LEN] = {"img/ochiD.jpg", "img/ochiN.jpg"};
  164. const char imgReplay[2][LEN] = {"img/replayD.jpg", "img/replayN.jpg"};
  165. const int pozJoystick[2][4] = {1008, 342, 1055, 390, 1008+24, 342, 1055+24, 390};
  166. const int pozCarte[2][4] = {1080, 460, 1128, 508, 1080-24, 461, 1128-24, 508};
  167. const int pozRotita[2][4] = {960, 576, 1007, 624, 960+24, 576, 1007+24, 624};
  168. const int pozX[2][4] = {984, 696, 1031, 743, 984-48, 696, 1031-48, 743};
  169. const int pozOm[2][4] = {1080+24, 312, 1128+23, 360, 1080, 312, 1127, 360};
  170. const int pozOchi[2][4] = {1032+24, 432, 1080+23, 480, 1032, 432, 1079, 480};
  171. const int pozReplay[2][4] = {984, 552, 1032, 599, 984, 552, 1032, 599};
  172.  
  173. // muzica si efecte sonore
  174. sf::Music muzicaFundal;
  175. sf::SoundBuffer bufferHover, bufferZi, bufferNoapte, bufferInainte, bufferInapoi, bufferSchimba, bufferVictorie, bufferEgal;
  176. sf::Sound sunetHover, sunetZi, sunetNoapte, sunetInainte, sunetInapoi, sunetSchimba, sunetVictorie, sunetEgal;
  177. const char sunetHit[6][LEN] = {"audio/hit1.wav", "audio/hit2.wav", "audio/hit3.wav", "audio/hit4.wav", "audio/hit5.wav", "audio/hit6.wav"};
  178.  
  179. // date joc
  180. int tabla[8][8], nr_mutari, nr_timp, nr_safe;
  181. int scor_j1, scor_j2, timp_limita, mutari_ramase, castigator;
  182. bool timp_expirat, joc_terminat;
  183. char txt_infoP1[2][LEN], txt_infoP2[2][LEN], txt_infoMutari[2][LEN], txt_infoTimer[LEN];
  184. int pozMutare[2]; // info
  185. char txt_mutare[LEN], txt_logs[101][LEN]; // istoric mutari
  186. struct pieseAI {int linie, coloana, status;} ai[8];
  187. int sizeAI, index_ai;
  188.  
  189. // estetica jocului
  190. int aspect_j1, aspect_j2, aspect_tabla;
  191. int mod, limba, fundal, mod_muzica, mod_sfx;
  192.  
  193. void Meniu();//Marian
  194. void JocNou();//Marian
  195. void Tutorial();//Marian
  196. void Setari();//Alex
  197. void Credits();//Marian
  198. void PVP();//Alex
  199. void PVIA();//Alex+Marian
  200. void Reluare();//Alex
  201. void Sfarsit(int cod=0,int altcod=0);//Alex
  202. void Restart(int cod=0);//Alex
  203. void Salveaza();Alex
  204.  
  205. char* itoa(int nr, char b[]) // converteste un nr in char* Marian
  206. {
  207. char const cifre[] = "0123456789";
  208. char* p = b;
  209. if(nr < 0)
  210. {
  211. *p++ = '-';
  212. nr *= -1;
  213. }
  214.  
  215. int aux = nr;
  216. do
  217. {
  218. ++p;
  219. aux = aux/10;
  220. }while(aux);
  221.  
  222. *p = '\0';
  223. do
  224. {
  225. *--p = cifre[nr%10];
  226. nr = nr/10;
  227. }while(nr);
  228.  
  229. return b;
  230. }
  231.  
  232. bool esteDeasupra(int x, int y, const int poz[2][4])
  233. {
  234. return x >= poz[limba][0] && x <= poz[limba][2] && y >= poz[limba][1] && y <= poz[limba][3];
  235. }
  236.  
  237. void initializareTabla(int cod=0) // 0 = razboi in 8, 1 = razboi in 4 Marian
  238. {
  239. // deseneaza tabla
  240. readimagefile(imgTabla[0][aspect_tabla], COORD1(pozTabla));
  241.  
  242. // resetare scoruri
  243. scor_j1 = scor_j2 = 0;
  244.  
  245. for(int i = 0; i < 8; i++)
  246. if(i%2 == 1)
  247. {
  248. // jucator negru
  249. tabla[0][i] = JUCATOR2;
  250. tabla[1][i] = 0;
  251.  
  252. // jucator alb
  253. tabla[6][i] = JUCATOR1;
  254. tabla[7][i] = 0;
  255. }
  256. else
  257. {
  258. // jucator negru
  259. tabla[0][i] = 0;
  260. tabla[1][i] = JUCATOR2;
  261.  
  262. // jucator alb
  263. tabla[6][i] = 0;
  264. tabla[7][i] = JUCATOR1;
  265. }
  266.  
  267. for(int i = 2; i < 6; i++)
  268. for(int j = 0; j < 8; j++) tabla[i][j] = 0; // zone libere
  269.  
  270. if(cod == 0 && nr_safe == 0) // razboi in 4 live
  271. for(int i = 0; i < 8; i++) tabla[1][i] = tabla[6][i] = 0;
  272. else if(cod == 1) // razboi in 4 replay
  273. for(int i = 0; i < 8; i++) tabla[1][i] = tabla[6][i] = 0;
  274.  
  275. sizeAI = 0;
  276. // piese ai
  277. for(int i = 0; i < 2; i++)
  278. for(int j = 0; j < 8; j++)
  279. if(tabla[i][j] == JUCATOR2)
  280. {
  281. ai[sizeAI].linie = i;
  282. ai[sizeAI].coloana = j;
  283. ai[sizeAI].status = 1;
  284. sizeAI++;
  285. }
  286.  
  287. //deseneaza piese
  288. for(int i = 0; i < 8; i++)
  289. for(int j = 0; j < 8; j++)
  290. {
  291. int x1, y1, x2, y2;
  292. x1 = j*LATURA + MARGINE_O;
  293. y1 = i*LATURA + MARGINE_V;
  294.  
  295. x2 = (j+1)*LATURA + MARGINE_O;
  296. y2 = (i+1)*LATURA + MARGINE_V;
  297.  
  298. if(tabla[i][j] == JUCATOR2) readimagefile(imgPiesaB[aspect_j2], x1+12, y1+12, x2-12, y2-12);
  299. else if(tabla[i][j] == JUCATOR1) readimagefile(imgPiesaA[aspect_j1], x1+12, y1+12, x2-12, y2-12);
  300. }
  301. }
  302.  
  303. int turaJucator()
  304. {
  305. return mutari_ramase%2 + 1;
  306. }
  307.  
  308. bool esteInauntru(int linie, int coloana)
  309. {
  310. return linie >= 0 && linie < 8 && coloana >= 0 && coloana < 8;
  311. }
  312.  
  313. bool esteBlocat(int linie, int coloana)//Alex
  314. {
  315. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  316. int blocaje = 0;
  317.  
  318. // numara cate piese se gasesc in vecinatate
  319. for(int d = 0; d < 4; d++)
  320. {
  321. int i = linie + di[d];
  322. int j = coloana + dj[d];
  323.  
  324. if(i < 0 || i >= 8 || j < 0 || j >= 8 || tabla[i][j] != 0) blocaje++;
  325. }
  326.  
  327. return blocaje == 4;
  328. }
  329.  
  330. int nrBlocaje(int linie, int coloana)//Alex
  331. {
  332. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  333. int blocaje = 0;
  334.  
  335. // numara cate piese se gasesc in vecinatate
  336. for(int d = 0; d < 4; d++)
  337. {
  338. int i = linie + di[d];
  339. int j = coloana + dj[d];
  340.  
  341. if(i < 0 || i >= 8 || j < 0 || j >= 8 || tabla[i][j] != 0) blocaje++;
  342. }
  343.  
  344. return blocaje;
  345. }
  346.  
  347. void determinaPozitie(int &linie, int &coloana)//Marian
  348. {
  349. int x, y;
  350. x = mousex();
  351. y = mousey();
  352.  
  353. linie = floor((1.0*y-MARGINE_V)/LATURA);
  354. coloana = floor((1.0*x-MARGINE_O)/LATURA);
  355. }
  356.  
  357. bool verificaSfarsit()
  358. {
  359. return (mutari_ramase <= 0 || scor_j1 == 8 || scor_j2 == 8);
  360. }
  361.  
  362. void deseneazaPiesa(int linie, int coloana, int cod)//Marian
  363. {
  364.  
  365. int x1, x2, y1, y2;
  366. x1 = coloana*LATURA + MARGINE_O;
  367. y1 = linie*LATURA + MARGINE_V;
  368.  
  369. x2 = (coloana+1)*LATURA + MARGINE_O;
  370. y2 = (linie+1)*LATURA + MARGINE_V;
  371.  
  372. readimagefile(imgPatrat[aspect_tabla], x1, y1, x2-1, y2-1); // deseneaza patrat fundal
  373.  
  374. if(cod == 1) readimagefile(imgPiesaA[aspect_j1], x1+12, y1+12, x2-12, y2-12);
  375. else if(cod == 2) readimagefile(imgPiesaB[aspect_j2], x1+12, y1+12, x2-12, y2-12);
  376. else if(cod == 3)
  377. {
  378. setfillstyle(SOLID_FILL, CULOARE_POSIBIL);
  379. bar(x1,y1,x2,y2);
  380. setfillstyle(SOLID_FILL, fundal);
  381. }
  382. }
  383.  
  384. void stergePiesa(int linie, int coloana)//Marian
  385. {
  386. int x1, x2, y1, y2;
  387.  
  388. x1 = coloana*LATURA + MARGINE_O;
  389. y1 = linie*LATURA + MARGINE_V;
  390.  
  391. x2 = (coloana+1)*LATURA + MARGINE_O;
  392. y2 = (linie+1)*LATURA + MARGINE_V;
  393.  
  394. readimagefile(imgPatrat[aspect_tabla], x1, y1, x2-1, y2-1);
  395. }
  396.  
  397. void deseneazaPosibile(int linie, int coloana)//Alex
  398. {
  399. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  400.  
  401. // evidentiaza zonele unde se poate efectua mutarea
  402. for(int d = 0; d < 4; d++)
  403. {
  404. int i = linie + di[d];
  405. int j = coloana + dj[d];
  406.  
  407. if(esteInauntru(i,j) && tabla[i][j] == 0)
  408. {
  409. tabla[i][j] = POSIBIL;
  410. deseneazaPiesa(i,j,POSIBIL);
  411. }
  412. }
  413. }
  414.  
  415. void stergePosibile(int linie, int coloana)//Alex
  416. {
  417. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  418.  
  419. for(int d = 0; d < 4; d++)
  420. {
  421. int i = linie + di[d];
  422. int j = coloana + dj[d];
  423.  
  424. if(esteInauntru(i,j) && tabla[i][j] == POSIBIL)
  425. {
  426. tabla[i][j] = 0;
  427. deseneazaPiesa(i,j,0);
  428. }
  429. }
  430. }
  431.  
  432. bool timpExpirat(time_t inceput, time_t sfarsit)
  433. {
  434. int timp = (sfarsit-inceput) / CLOCKS_PER_SEC;
  435. return (timp >= nr_timp+1);
  436. }
  437.  
  438. void skipMutare(bool &skip_mutare)//Alex
  439. {
  440. if(ismouseclick(WM_MBUTTONDOWN) || ismouseclick(WM_MBUTTONDBLCLK))
  441. {
  442. clearmouseclick(WM_MBUTTONDOWN);
  443. clearmouseclick(WM_MBUTTONDBLCLK);
  444. skip_mutare = true;
  445. }
  446. if(kbhit())
  447. {
  448. char c = getch();
  449. skip_mutare = (c==32);
  450. }
  451. }
  452.  
  453. void verificaButoane(int x, int y, int cod=0)//Alex
  454. {
  455. // buton muzica
  456. if(esteDeasupra(x,y,pozMuzica))
  457. {
  458. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  459. {
  460. muzicaFundal.stop();
  461. mod_muzica = OPRIT;
  462. }
  463. else
  464. {
  465. muzicaFundal.play();
  466. mod_muzica = PORNIT;
  467. }
  468.  
  469. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  470. }
  471. // buton sfx
  472. else if(esteDeasupra(x,y,pozSfx))
  473. {
  474. mod_sfx = (mod_sfx+1) % 2;
  475. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  476. }
  477. // buton abandon
  478. else if(esteDeasupra(x,y,pozAbandon))
  479. {
  480. Sfarsit(0,cod);
  481. readimagefile(imgAbandon[mod][limba], COORD1(pozAbandon));
  482. }
  483. }
  484.  
  485. void vulnerabilitate(int blocaje, bool &mutat)//Alex
  486. {
  487. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  488.  
  489. for(int k = 0; k < sizeAI && !mutat; k++)
  490. {
  491. if(ai[k].status == 1) // putem folosi aceasta piesa
  492. {
  493. for(int d = 0; d < 4 && !mutat; d++) // simulam mutarile in toate pozitiile libere
  494. {
  495. int l1 = ai[k].linie+di[d];
  496. int c1 = ai[k].coloana+dj[d];
  497.  
  498. if(esteInauntru(l1,c1) && tabla[l1][c1] == 0) // ar putea fi o mutare valida
  499. {
  500. for(int d = 0; d < 4 && !mutat; d++) // ma uit la vecinii care ar putea aparea in acest caz
  501. {
  502. int l2 = l1+di[d];
  503. int c2 = c1+dj[d];
  504.  
  505. if(esteInauntru(l2,c2) && tabla[l2][c2] == JUCATOR1) // vecin inamic, numar de cate blocaje este inconjurat
  506. {
  507. if(nrBlocaje(l2,c2) == 3) // piesa vulnerabila, o atac
  508. {
  509. mutat = true;
  510. // actualizeaza info mutare
  511. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  512. strcat(txt_mutare,iab[ai[k].coloana]); strcat(txt_mutare,i08[ai[k].linie]);
  513. strcat(txt_mutare,"-");
  514. strcat(txt_mutare,iab[c1]); strcat(txt_mutare,i08[l1]);
  515. strcat(txt_mutare," ");
  516.  
  517. tabla[ai[k].linie][ai[k].coloana] = 0;
  518. stergePiesa(ai[k].linie,ai[k].coloana);
  519. ai[k].linie = l1;
  520. ai[k].coloana = c1;
  521. tabla[l1][c1] = JUCATOR2;
  522. deseneazaPiesa(l1,c1,JUCATOR2);
  523. }
  524. }
  525. }
  526. }
  527. }
  528. }
  529. }
  530. }
  531.  
  532. void mutareAi(int index)//Alex
  533. {
  534. index_ai = index;
  535. sizeAI = (nr_safe == 0 ? 4:8);
  536. // daca pot elimina piese -> elimin
  537. // daca pot bloca piese -> blochez + elimin
  538. // daca am o piesa inconjurata in 3 parti -> mut in partea libera
  539. // daca pot, mut o piesa random inainte
  540. // altfel, mut o piesa random
  541. // nu pot face nimic
  542.  
  543. itoa(index_ai,txt_mutare); strcat(txt_mutare,". ");
  544.  
  545. int di[4] = {-1,-1,1,1}, dj[4] = {-1,1,-1,1};
  546. bool mutat = false, eliminat = false;
  547.  
  548. // elimin piesele inamice blocate
  549. for(int i = 0; i < 8; i++)
  550. for(int j = 0; j < 8; j++)
  551. if(index_ai > nr_safe && tabla[i][j] == JUCATOR1 && esteBlocat(i,j))
  552. {
  553. eliminat = true;
  554. tabla[i][j] = 0;
  555. stergePiesa(i,j);
  556. scor_j2++;
  557.  
  558. // actualizeaza info mutare
  559. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  560. strcat(txt_mutare,"(-");
  561. strcat(txt_mutare,iab[j]); strcat(txt_mutare,i08[i]);
  562. strcat(txt_mutare,") ");
  563. }
  564.  
  565. // caut piese inamice foarte vulnerabile
  566. vulnerabilitate(3,mutat);
  567. // nu am gasit, caut piese mai putin vulnerabile
  568. if(!mutat) vulnerabilitate(2,mutat);
  569. // nici acum nu am gasit, caut cele mai putin vulnerabile piese
  570. if(!mutat) vulnerabilitate(1,mutat);
  571.  
  572. bool sunt_blocat = true;
  573. for(int i = 0; i < sizeAI && !mutat; i++)
  574. if(ai[i].status == 1)
  575. {
  576. if(nrBlocaje(ai[i].linie,ai[i].coloana) < 4)
  577. {
  578. sunt_blocat = false;
  579. break;
  580. }
  581. }
  582. if(!sunt_blocat)
  583. {
  584. // ghinion! dar poate o piesa de a mea este in pericol
  585. // for(int i = 0; i < sizeAI && !mutat; i++,cout<<5)
  586. // if(ai[i].status == 1)
  587. // {
  588. // if(nrBlocaje(ai[i].linie,ai[i].coloana) == 3) // piesa inconjurata de 3 blocaje, o mut in siguranta
  589. // {
  590. // for(int d = 0; d < 4; d++)
  591. // {
  592. // cout<<6;
  593. // int l1 = ai[i].linie+di[d];
  594. // int c1 = ai[i].coloana+dj[d];
  595. //
  596. // if(esteInauntru(l1,c1) && tabla[l1][c1] == 0)
  597. // {
  598. // mutat = true;
  599. // tabla[ai[i].linie][ai[i].coloana] = 0;
  600. // stergePiesa(ai[i].linie,ai[i].coloana);
  601. // ai[i].linie = l1;
  602. // ai[i].coloana = c1;
  603. // tabla[l1][c1] = JUCATOR2;
  604. // deseneazaPiesa(l1,c1,JUCATOR2);
  605. // }
  606. // }
  607. // }
  608. // }
  609.  
  610. // nicio piesa in pericol, mut o piesa la intamplare
  611. bool pot_inainte = false;
  612. for(int i = 0; i < sizeAI; i++)
  613. {
  614. if(ai[i].status == 1)
  615. {
  616. int l = ai[i].linie-1;
  617. int c1 = ai[i].coloana-1;
  618. int c2 = ai[i].coloana+1;
  619. if(esteInauntru(l,c1) && tabla[l][c1] == 0)
  620. {
  621. pot_inainte = true;
  622. break;
  623. }
  624. if(esteInauntru(l,c2) && tabla[l][c2] == 0)
  625. {
  626. pot_inainte = true;
  627. break;
  628. }
  629. }
  630. }
  631.  
  632. if(pot_inainte) // pot muta agresiv
  633. {
  634. while(!mutat)
  635. {
  636. int r = rand()%sizeAI;
  637. if(ai[r].status == 1)
  638. {
  639. int l = ai[r].linie+1;
  640. int c1 = ai[r].coloana-1;
  641. int c2 = ai[r].coloana+1;
  642. if(esteInauntru(l,c1) && tabla[l][c1] == 0)
  643. {
  644. mutat = true;
  645. // actualizeaza info mutare
  646. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  647. strcat(txt_mutare,iab[ai[r].coloana]); strcat(txt_mutare,i08[ai[r].linie]);
  648. strcat(txt_mutare,"-");
  649. strcat(txt_mutare,iab[c1]); strcat(txt_mutare,i08[l]);
  650. strcat(txt_mutare," ");
  651.  
  652. tabla[ai[r].linie][ai[r].coloana] = 0;
  653. stergePiesa(ai[r].linie,ai[r].coloana);
  654. ai[r].linie = l;
  655. ai[r].coloana = c1;
  656. tabla[l][c1] = JUCATOR2;
  657. deseneazaPiesa(l,c1,JUCATOR2);
  658. break;
  659. }
  660. if(esteInauntru(l,c2) && tabla[l][c2] == 0)
  661. {
  662. mutat = true;
  663. // actualizeaza info mutare
  664. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  665. strcat(txt_mutare,iab[ai[r].coloana]); strcat(txt_mutare,i08[ai[r].linie]);
  666. strcat(txt_mutare,"-");
  667. strcat(txt_mutare,iab[c2]); strcat(txt_mutare,i08[l]);
  668. strcat(txt_mutare," ");
  669.  
  670. tabla[ai[r].linie][ai[r].coloana] = 0;
  671. stergePiesa(ai[r].linie,ai[r].coloana);
  672. ai[r].linie = l;
  673. ai[r].coloana = c2;
  674. tabla[l][c2] = JUCATOR2;
  675. deseneazaPiesa(l,c2,JUCATOR2);
  676. break;
  677. }
  678. }
  679. }
  680. }
  681. else // mut in alta parte
  682. {
  683. while(!mutat)
  684. {
  685. int r = rand()%sizeAI;
  686. if(ai[r].status == 1)
  687. {
  688. for(int d = 0; d < 4 && !mutat; d++)
  689. {
  690. int l = ai[r].linie+di[d];
  691. int c = ai[r].coloana+dj[d];
  692.  
  693. if(esteInauntru(l,c) && tabla[l][c] == 0)
  694. {
  695. mutat = true;
  696. // actualizeaza info mutare
  697. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  698. strcat(txt_mutare,iab[ai[r].coloana]); strcat(txt_mutare,i08[ai[r].linie]);
  699. strcat(txt_mutare,"-");
  700. strcat(txt_mutare,iab[c]); strcat(txt_mutare,i08[l]);
  701. strcat(txt_mutare," ");
  702.  
  703. tabla[ai[r].linie][ai[r].coloana] = 0;
  704. stergePiesa(ai[r].linie,ai[r].coloana);
  705. ai[r].linie = l;
  706. ai[r].coloana = c;
  707. tabla[l][c] = JUCATOR2;
  708. deseneazaPiesa(l,c,JUCATOR2);
  709. }
  710. }
  711. }
  712. }
  713. }
  714. }
  715.  
  716. // elimin eventualele piese inamice blocate
  717. for(int i = 0; i < 8; i++)
  718. for(int j = 0; j < 8; j++)
  719. if(index_ai > nr_safe && tabla[i][j] == JUCATOR1 && esteBlocat(i,j))
  720. {
  721. eliminat = true;
  722. tabla[i][j] = 0;
  723. stergePiesa(i,j);
  724. scor_j2++;
  725.  
  726. // actualizeaza info mutare
  727. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  728. strcat(txt_mutare,"(-");
  729. strcat(txt_mutare,iab[j]); strcat(txt_mutare,i08[i]);
  730. strcat(txt_mutare,") ");
  731. }
  732.  
  733. if(!mutat && !eliminat) strcat(txt_mutare, "x"); // atat s-a putut
  734.  
  735. // actualizare mutari ramase si text nr mutari
  736. mutari_ramase--;
  737.  
  738. char txtNrMutari[12]; itoa(mutari_ramase, txtNrMutari);
  739. char txtInfoMutari[LEN]; strcpy(txtInfoMutari,txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  740. settextstyle(8,0,3);
  741. bar(pozRamase[0]-200,pozRamase[1]-100,pozRamase[0]+150,pozRamase[1]+100);
  742. outtextxy(COORD2(pozRamase), txtInfoMutari);
  743.  
  744. // actualizare text tura jucator
  745. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  746. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  747.  
  748. if(turaJucator() == JUCATOR1) outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  749. else outtextxy(COORD2(pozRand2), txt_infoP2[limba]);
  750.  
  751. // actualizare text scor
  752. settextstyle(3,0,4);
  753. char txtScor1[12], txtScor2[12]; itoa(scor_j1,txtScor1); itoa(scor_j2,txtScor2);
  754. char txtScor[LEN] = ""; strcat(txtScor,txtScor1); strcat(txtScor," - "); strcat(txtScor,txtScor2);
  755. outtextxy(COORD2(pozScor), txtScor);
  756.  
  757. // actualizeaza tabela istoric
  758. if((index_ai-1)%23 == 0) // tabela este plina, o sterg
  759. {
  760. readimagefile(imgIstoric[mod], COORD1(pozIstoric));
  761. pozMutare[1] = pozIstoric[limba][1]+12;
  762. }
  763. strcpy(txt_logs[index_ai-1], txt_mutare);
  764. strcpy(txt_logs[index_ai], "NULL");
  765.  
  766. settextstyle(3,0,1);
  767. settextjustify(LEFT_TEXT,TOP_TEXT);
  768. outtextxy(COORD2(pozMutare), txt_mutare);
  769. pozMutare[1] += 24;
  770. settextjustify(CENTER_TEXT,CENTER_TEXT);
  771. }
  772.  
  773. void mutarePiesa(int cod=0, int altcod=0) // 0 = pvp, 1 = pvai Alex
  774. {
  775. int index_mutare = nr_mutari-mutari_ramase+1;
  776. if(cod == 1)
  777. {
  778. mutareAi(index_mutare);
  779. return;
  780. }
  781. itoa(index_mutare,txt_mutare); strcat(txt_mutare,". ");
  782.  
  783. bool piesa_mutata = false, piesa_eliminata = false;
  784. bool skip_mutare = false;
  785.  
  786. time_t inceput = clock();
  787. time_t sfarsit = NULL;
  788. int timer1 = inceput;
  789. int timer2 = NULL;
  790.  
  791. // actualizeaza text timer
  792. settextstyle(3,0,8);
  793. char txtTimp[12]; itoa(timp_limita,txtTimp);
  794. if(timp_limita < 10) txtTimp[1] = txtTimp[0], txtTimp[0] = '0', txtTimp[2] = NULL;
  795. char txtInfoTimer[LEN] = "00:"; strcat(txtInfoTimer,txtTimp);
  796. outtextxy(COORD2(pozTimer), txtInfoTimer);
  797.  
  798. do
  799. {
  800. int x = mousex();
  801. int y = mousey();
  802.  
  803. // buton abandon
  804. if(esteDeasupra(x,y,pozAbandon)) readimagefile(imgAbandon[(mod+1)%2][limba],COORD1(pozAbandon));
  805. else readimagefile(imgAbandon[mod][limba],COORD1(pozAbandon));
  806.  
  807. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  808. {
  809. clearmouseclick(WM_LBUTTONDOWN);
  810. clearmouseclick(WM_LBUTTONDBLCLK);
  811.  
  812. // inceput MUTARE PIESA
  813. if(piesa_mutata == false)
  814. {
  815. int linie1, coloana1;
  816. determinaPozitie(linie1,coloana1);
  817.  
  818. if(esteInauntru(linie1,coloana1) && tabla[linie1][coloana1] == turaJucator()) // piesa valida
  819. {
  820. deseneazaPosibile(linie1,coloana1); // deseneaza ghid
  821.  
  822. do
  823. {
  824. x = mousex();
  825. y = mousey();
  826.  
  827. // buton abandon
  828. if(esteDeasupra(x,y,pozAbandon)) readimagefile(imgAbandon[(mod+1)%2][limba],COORD1(pozAbandon));
  829. else readimagefile(imgAbandon[mod][limba],COORD1(pozAbandon));
  830.  
  831. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK)) // selecteaza pozitia in care vrei sa muti piesa
  832. {
  833. clearmouseclick(WM_LBUTTONDOWN);
  834. clearmouseclick(WM_LBUTTONDBLCLK);
  835.  
  836. verificaButoane(x,y);
  837.  
  838. int linie2, coloana2;
  839. determinaPozitie(linie2,coloana2);
  840.  
  841. if(esteInauntru(linie2,coloana2) && abs(linie1-linie2) == 1 && abs(coloana1-coloana2) == 1 && (tabla[linie2][coloana2] == 0 || tabla[linie2][coloana2] == POSIBIL)) // pozitie valida
  842. {
  843. piesa_mutata = true; // piesa a fost mutata
  844.  
  845. tabla[linie1][coloana1] = 0; // sterg piesa
  846. stergePiesa(linie1,coloana1); // de pe vechia pozitie
  847.  
  848. tabla[linie2][coloana2] = turaJucator(); // desenez piesa
  849. deseneazaPiesa(linie2,coloana2,turaJucator()); // pe noua pozitie
  850.  
  851. stergePosibile(linie1,coloana1); // sterge ghid
  852.  
  853. // actualizeaza info mutare
  854. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  855. strcat(txt_mutare,iab[coloana1]); strcat(txt_mutare,i08[linie1]);
  856. strcat(txt_mutare,"-");
  857. strcat(txt_mutare,iab[coloana2]); strcat(txt_mutare,i08[linie2]);
  858. strcat(txt_mutare," ");
  859.  
  860. // sunet mutare piesa
  861. if(mod_sfx == PORNIT)
  862. {
  863. int rnd = rand()%6;
  864. sf::SoundBuffer rndBfr; rndBfr.loadFromFile(sunetHit[rnd]);
  865. sf::Sound rndSnd(rndBfr); rndSnd.play();
  866. while(rndSnd.getStatus());
  867. }
  868. }
  869. }
  870. else if(ismouseclick(WM_RBUTTONDOWN)) break; // actiune invalida -> anulare mutare
  871.  
  872. // actualizeaza text timer
  873. if(timer2-timer1 >= CLOCKS_PER_SEC)
  874. {
  875. timp_limita--;
  876. char txtTimp[12]; itoa(timp_limita,txtTimp);
  877. if(timp_limita < 10) txtTimp[1] = txtTimp[0], txtTimp[0] = '0', txtTimp[2] = NULL;
  878. char txtInfoTimer[LEN] = "00:"; strcat(txtInfoTimer,txtTimp);
  879. outtextxy(COORD2(pozTimer), txtInfoTimer);
  880.  
  881. timer1 = timer2;
  882. }
  883.  
  884. sfarsit = clock(); timer2 = sfarsit;
  885. verificaSfarsit(); // verifica starea jocului
  886. timp_expirat = timpExpirat(inceput,sfarsit); // actualizeaza timer
  887. skipMutare(skip_mutare); // daca jucatorul sare peste mutare/si-a incheiat mutarea
  888. }while(timp_expirat == false && joc_terminat == false && piesa_mutata == false && skip_mutare == false);
  889.  
  890. stergePosibile(linie1,coloana1); // sterge ghid
  891. }
  892. else if(!cod) verificaButoane(x,y,altcod);
  893. }
  894. // sfarsit MUTARE PIESA
  895. else if(!cod) verificaButoane(x,y,altcod);
  896. }
  897. else if(ismouseclick(WM_RBUTTONDOWN))
  898. {
  899. clearmouseclick(WM_RBUTTONDOWN);
  900.  
  901. // inceput ELIMINARE PIESA
  902. int linie1, coloana1;
  903. determinaPozitie(linie1,coloana1);
  904.  
  905. if(index_mutare >= nr_safe && tabla[linie1][coloana1] != 0 && esteInauntru(linie1,coloana1) && esteBlocat(linie1,coloana1)) // sterge piesa valida
  906. {
  907. piesa_eliminata = true;
  908.  
  909. // actualizeaza scor
  910. if(tabla[linie1][coloana1] == JUCATOR1) scor_j2++;
  911. else scor_j1++;
  912.  
  913. // daca joc vs ai
  914. if(altcod == 1)
  915. {
  916. for(int s = 0; s < sizeAI; s++)
  917. if(ai[s].linie == linie1 && ai[s].coloana == coloana1)
  918. {
  919. ai[s].status = 0;
  920. break;
  921. }
  922. }
  923.  
  924. tabla[linie1][coloana1] = 0;
  925. stergePiesa(linie1,coloana1); // sterge piesa
  926.  
  927. // actualizeaza info mutare
  928. char iab[8][2]={"a","b","c","d","e","f","g","h"}, i08[8][2]={"8","7","6","5","4","3","2","1"};
  929. strcat(txt_mutare,"(-");
  930. strcat(txt_mutare,iab[coloana1]); strcat(txt_mutare,i08[linie1]);
  931. strcat(txt_mutare,") ");
  932.  
  933. // actualizare text scor
  934. settextstyle(3,0,4);
  935. char txtScor1[12], txtScor2[12]; itoa(scor_j1,txtScor1); itoa(scor_j2,txtScor2);
  936. char txtScor[LEN] = ""; strcat(txtScor,txtScor1); strcat(txtScor," - "); strcat(txtScor,txtScor2);
  937. outtextxy(COORD2(pozScor), txtScor);
  938. settextstyle(3,0,8);
  939. }
  940. // sfarsit ELIMINARE PIESA
  941. }
  942.  
  943. // actualizeaza text timer
  944. sfarsit = clock(); timer2 = sfarsit;
  945. if(timer2-timer1 >= CLOCKS_PER_SEC)
  946. {
  947. timp_limita--;
  948. char txtTimp[12]; itoa(timp_limita,txtTimp);
  949. if(timp_limita < 10) txtTimp[1] = txtTimp[0], txtTimp[0] = '0', txtTimp[2] = NULL;
  950. char txtInfoTimer[LEN] = "00:"; strcat(txtInfoTimer,txtTimp);
  951. outtextxy(COORD2(pozTimer), txtInfoTimer);
  952.  
  953. timer1 = timer2;
  954. }
  955. verificaSfarsit(); // verifica starea jocului
  956. timp_expirat = timpExpirat(inceput,sfarsit); // actualizeaza timer
  957. skipMutare(skip_mutare); // daca jucatorul sare peste mutare/si-a incheiat mutarea
  958. }while(timp_expirat == false && joc_terminat == false && skip_mutare == false);
  959.  
  960. if(piesa_mutata == false && piesa_eliminata == false) strcat(txt_mutare, "x");
  961.  
  962. // actualizare mutari ramase si text nr mutari
  963. mutari_ramase--;
  964.  
  965. char txtNrMutari[12]; itoa(mutari_ramase, txtNrMutari);
  966. char txtInfoMutari[LEN]; strcpy(txtInfoMutari,txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  967. settextstyle(8,0,3);
  968. bar(pozRamase[0]-200,pozRamase[1]-100,pozRamase[0]+150,pozRamase[1]+100);
  969. outtextxy(COORD2(pozRamase), txtInfoMutari);
  970.  
  971. // actualizare text tura jucator
  972. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  973. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  974.  
  975. if(turaJucator() == JUCATOR1) outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  976. else outtextxy(COORD2(pozRand2), txt_infoP2[limba]);
  977.  
  978. // actualizare text scor
  979. settextstyle(3,0,4);
  980. char txtScor1[12], txtScor2[12]; itoa(scor_j1,txtScor1); itoa(scor_j2,txtScor2);
  981. char txtScor[LEN] = ""; strcat(txtScor,txtScor1); strcat(txtScor," - "); strcat(txtScor,txtScor2);
  982. outtextxy(COORD2(pozScor), txtScor);
  983.  
  984. // actualizeaza tabela istoric
  985. if((index_mutare-1)%23 == 0) // tabela este plina, o sterg
  986. {
  987. readimagefile(imgIstoric[mod], COORD1(pozIstoric));
  988. pozMutare[1] = pozIstoric[limba][1]+12;
  989. }
  990. strcpy(txt_logs[index_mutare-1], txt_mutare);
  991. strcpy(txt_logs[index_mutare], "NULL");
  992.  
  993. settextstyle(3,0,1);
  994. settextjustify(LEFT_TEXT,TOP_TEXT);
  995. outtextxy(COORD2(pozMutare), txt_mutare);
  996. pozMutare[1] += 24;
  997. settextjustify(CENTER_TEXT,CENTER_TEXT);
  998. }
  999.  
  1000. void Initializari()//Marian
  1001. {
  1002. fundal = WHITE;
  1003.  
  1004. nr_mutari = 50;
  1005. nr_timp = 10;
  1006. nr_safe = 6;
  1007.  
  1008. muzicaFundal.openFromFile("audio/bgm.wav");
  1009. muzicaFundal.setLoop(true); muzicaFundal.setVolume(50.f); muzicaFundal.play();
  1010.  
  1011. bufferHover.loadFromFile("audio/mouseHover.wav");
  1012. bufferInainte.loadFromFile("audio/mouseForward.wav");
  1013. bufferInapoi.loadFromFile("audio/mouseBack.wav");
  1014. bufferZi.loadFromFile("audio/mouseLight.wav");
  1015. bufferNoapte.loadFromFile("audio/mouseDark.wav");
  1016. bufferSchimba.loadFromFile("audio/mouseSettings.wav");
  1017. bufferVictorie.loadFromFile("audio/victory.wav");
  1018. bufferEgal.loadFromFile("audio/draw.wav");
  1019.  
  1020. sunetHover.setBuffer(bufferHover);
  1021. sunetInainte.setBuffer(bufferInainte);
  1022. sunetInapoi.setBuffer(bufferInapoi);
  1023. sunetZi.setBuffer(bufferZi);
  1024. sunetNoapte.setBuffer(bufferNoapte);
  1025. sunetSchimba.setBuffer(bufferSchimba);
  1026. sunetVictorie.setBuffer(bufferVictorie);
  1027. sunetEgal.setBuffer(bufferEgal);
  1028. }
  1029.  
  1030. void Meniu()
  1031. {
  1032. // afiseaza fundal si butoane
  1033. setfillstyle(SOLID_FILL, fundal);
  1034. bar(0,0,LUNGIME,LATIME);
  1035.  
  1036. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1037. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1038.  
  1039. readimagefile(imgTitlu[mod][limba], COORD1(pozTitlu));
  1040. readimagefile(imgCredit[mod][limba], COORD1(pozCredit));
  1041.  
  1042. readimagefile(imgJocNou[mod][limba], COORD1(pozJocNou));
  1043. readimagefile(imgTutorial[mod][limba], COORD1(pozTutorial));
  1044. readimagefile(imgSetari[mod][limba], COORD1(pozSetari));
  1045. readimagefile(imgIesire[mod][limba], COORD1(pozIesire));
  1046.  
  1047. readimagefile(imgSoare[NOAPTE], COORD1(pozSoare));
  1048. readimagefile(imgLuna[ZI], COORD1(pozLuna));
  1049.  
  1050. readimagefile(imgRo[mod][limba], COORD1(pozRo));
  1051. readimagefile(imgEn[mod][limba], COORD1(pozEn));
  1052.  
  1053. // hover si click
  1054. while(true)
  1055. {
  1056. clearmouseclick(WM_LBUTTONDOWN);
  1057. clearmouseclick(WM_MOUSEMOVE);
  1058.  
  1059. int x = mousex();
  1060. int y = mousey();
  1061.  
  1062. // buton muzica
  1063. if(esteDeasupra(x,y,pozMuzica))
  1064. {
  1065. while(true)
  1066. {
  1067. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1068. {
  1069. clearmouseclick(WM_LBUTTONDOWN);
  1070. clearmouseclick(WM_LBUTTONDBLCLK);
  1071. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  1072. {
  1073. muzicaFundal.stop();
  1074. mod_muzica = OPRIT;
  1075. }
  1076. else
  1077. {
  1078. muzicaFundal.play();
  1079. mod_muzica = PORNIT;
  1080. }
  1081.  
  1082. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1083. }
  1084. if(ismouseclick(WM_MOUSEMOVE))
  1085. {
  1086. clearmouseclick(WM_MOUSEMOVE);
  1087. x = mousex();
  1088. y = mousey();
  1089.  
  1090. if(!esteDeasupra(x,y,pozMuzica)) break;
  1091. }
  1092. }
  1093. }
  1094. // buton sfx
  1095. else if(esteDeasupra(x,y,pozSfx))
  1096. {
  1097. while(true)
  1098. {
  1099. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1100. {
  1101. clearmouseclick(WM_LBUTTONDOWN);
  1102. clearmouseclick(WM_LBUTTONDBLCLK);
  1103. mod_sfx = (mod_sfx+1) % 2;
  1104.  
  1105. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1106. }
  1107. if(ismouseclick(WM_MOUSEMOVE))
  1108. {
  1109. clearmouseclick(WM_MOUSEMOVE);
  1110. x = mousex();
  1111. y = mousey();
  1112.  
  1113. if(!esteDeasupra(x,y,pozSfx)) break;
  1114. }
  1115. }
  1116. }
  1117. // buton joc nou
  1118. else if(esteDeasupra(x,y,pozJocNou))
  1119. {
  1120. if(mod_sfx == PORNIT) sunetHover.play();
  1121. readimagefile(imgJocNou[(mod+1)%2][limba], COORD1(pozJocNou));
  1122.  
  1123. bar(STERGE(pozJoystick));
  1124. readimagefile(imgJoystick[mod], COORD1(pozJoystick));
  1125.  
  1126. while(true)
  1127. {
  1128. if(ismouseclick(WM_LBUTTONDOWN))
  1129. {
  1130. clearmouseclick(WM_LBUTTONDOWN);
  1131. if(mod_sfx == PORNIT) sunetInainte.play();
  1132.  
  1133. JocNou();
  1134. return;
  1135. }
  1136. if(ismouseclick(WM_MOUSEMOVE))
  1137. {
  1138. clearmouseclick(WM_MOUSEMOVE);
  1139. x = mousex();
  1140. y = mousey();
  1141.  
  1142. if(!esteDeasupra(x,y,pozJocNou))
  1143. {
  1144. readimagefile(imgJocNou[mod][limba], COORD1(pozJocNou));
  1145. bar(STERGE(pozJoystick));
  1146. break;
  1147. }
  1148. }
  1149. }
  1150. }
  1151. // buton cum se joaca
  1152. else if(esteDeasupra(x,y,pozTutorial))
  1153. {
  1154. if(mod_sfx == PORNIT) sunetHover.play();
  1155.  
  1156. readimagefile(imgTutorial[(mod+1)%2][limba], COORD1(pozTutorial));
  1157.  
  1158. bar(STERGE(pozCarte));
  1159. readimagefile(imgCarte[mod], COORD1(pozCarte));
  1160.  
  1161. while(true)
  1162. {
  1163. if(ismouseclick(WM_LBUTTONDOWN))
  1164. {
  1165. clearmouseclick(WM_LBUTTONDOWN);
  1166. if(mod_sfx == PORNIT) sunetInainte.play();
  1167.  
  1168. Tutorial();
  1169. return;
  1170. }
  1171. if(ismouseclick(WM_MOUSEMOVE))
  1172. {
  1173. clearmouseclick(WM_MOUSEMOVE);
  1174. x = mousex();
  1175. y = mousey();
  1176.  
  1177. if(!esteDeasupra(x,y,pozTutorial))
  1178. {
  1179. readimagefile(imgTutorial[mod][limba], COORD1(pozTutorial));
  1180. bar(STERGE(pozCarte));
  1181. break;
  1182. }
  1183. }
  1184. }
  1185. }
  1186. // buton setari
  1187. else if(esteDeasupra(x,y,pozSetari))
  1188. {
  1189. if(mod_sfx == PORNIT) sunetHover.play();
  1190.  
  1191. readimagefile(imgSetari[(mod+1)%2][limba], COORD1(pozSetari));
  1192.  
  1193. bar(STERGE(pozRotita));
  1194. readimagefile(imgRotita[mod], COORD1(pozRotita));
  1195.  
  1196. while(true)
  1197. {
  1198. if(ismouseclick(WM_LBUTTONDOWN))
  1199. {
  1200. clearmouseclick(WM_LBUTTONDOWN);
  1201. if(mod_sfx == PORNIT) sunetInainte.play();
  1202.  
  1203. Setari();
  1204. return;
  1205. }
  1206. if(ismouseclick(WM_MOUSEMOVE))
  1207. {
  1208. clearmouseclick(WM_MOUSEMOVE);
  1209. x = mousex();
  1210. y = mousey();
  1211.  
  1212. if(!esteDeasupra(x,y,pozSetari))
  1213. {
  1214. readimagefile(imgSetari[mod][limba], COORD1(pozSetari));
  1215. bar(STERGE(pozRotita));
  1216. break;
  1217. }
  1218. }
  1219. }
  1220. }
  1221. // buton iesire
  1222. else if(esteDeasupra(x,y,pozIesire))
  1223. {
  1224. if(mod_sfx == PORNIT) sunetHover.play();
  1225.  
  1226. readimagefile(imgIesire[(mod+1)%2][limba], COORD1(pozIesire));
  1227.  
  1228. bar(STERGE(pozX));
  1229. readimagefile(imgX[mod], COORD1(pozX));
  1230.  
  1231. while(true)
  1232. {
  1233. if(ismouseclick(WM_LBUTTONDOWN)) exit(0);
  1234. if(ismouseclick(WM_MOUSEMOVE))
  1235. {
  1236. clearmouseclick(WM_MOUSEMOVE);
  1237. x = mousex();
  1238. y = mousey();
  1239.  
  1240. if(!esteDeasupra(x,y,pozIesire))
  1241. {
  1242. readimagefile(imgIesire[mod][limba], COORD1(pozIesire));
  1243. bar(STERGE(pozX));
  1244. break;
  1245. }
  1246. }
  1247. }
  1248. }
  1249. // buton credits
  1250. else if(esteDeasupra(x,y,pozCredit))
  1251. {
  1252. if(mod_sfx == PORNIT) sunetHover.play();
  1253.  
  1254. readimagefile(imgCredit[(mod+1)%2][limba], COORD1(pozCredit));
  1255.  
  1256. while(true)
  1257. {
  1258. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1259. {
  1260. clearmouseclick(WM_LBUTTONDOWN);
  1261. clearmouseclick(WM_LBUTTONDBLCLK);
  1262. if(mod_sfx == PORNIT) sunetInainte.play();
  1263.  
  1264. Credits();
  1265. return;
  1266. }
  1267. if(ismouseclick(WM_MOUSEMOVE))
  1268. {
  1269. clearmouseclick(WM_MOUSEMOVE);
  1270. x = mousex();
  1271. y = mousey();
  1272.  
  1273. if(!esteDeasupra(x,y,pozCredit))
  1274. {
  1275. readimagefile(imgCredit[mod][limba], COORD1(pozCredit));
  1276. break;
  1277. }
  1278. }
  1279. }
  1280. }
  1281. // buton zi
  1282. else if(esteDeasupra(x,y,pozSoare) && mod == NOAPTE)
  1283. {
  1284. if(mod_sfx == PORNIT) sunetHover.play();
  1285.  
  1286. readimagefile(imgSoare[ZI], COORD1(pozSoare));
  1287. readimagefile(imgLuna[NOAPTE], COORD1(pozLuna));
  1288.  
  1289. while(true)
  1290. {
  1291. if(ismouseclick(WM_LBUTTONDOWN))
  1292. {
  1293. clearmouseclick(WM_LBUTTONDOWN);
  1294. if(mod_sfx == PORNIT) sunetZi.play();
  1295.  
  1296. mod = ZI; fundal = WHITE;
  1297. Meniu();
  1298. return;
  1299. }
  1300. if(ismouseclick(WM_MOUSEMOVE))
  1301. {
  1302. clearmouseclick(WM_MOUSEMOVE);
  1303. x = mousex();
  1304. y = mousey();
  1305.  
  1306. if(!esteDeasupra(x,y,pozSoare))
  1307. {
  1308. readimagefile(imgSoare[NOAPTE], COORD1(pozSoare));
  1309. readimagefile(imgLuna[ZI], COORD1(pozLuna));
  1310. break;
  1311. }
  1312. }
  1313. }
  1314. }
  1315. // buton noapte
  1316. else if(esteDeasupra(x,y,pozLuna) && mod == ZI)
  1317. {
  1318. if(mod_sfx == PORNIT) sunetHover.play();
  1319.  
  1320. readimagefile(imgLuna[NOAPTE], COORD1(pozLuna));
  1321. readimagefile(imgSoare[ZI], COORD1(pozSoare));
  1322.  
  1323. while(true)
  1324. {
  1325. if(ismouseclick(WM_LBUTTONDOWN))
  1326. {
  1327. clearmouseclick(WM_LBUTTONDOWN);
  1328. if(mod_sfx == PORNIT) sunetNoapte.play();
  1329.  
  1330. mod = NOAPTE; fundal = BLACK;
  1331. Meniu();
  1332. return;
  1333. }
  1334. if(ismouseclick(WM_MOUSEMOVE))
  1335. {
  1336. clearmouseclick(WM_MOUSEMOVE);
  1337. x = mousex();
  1338. y = mousey();
  1339.  
  1340. if(!esteDeasupra(x,y,pozLuna))
  1341. {
  1342. readimagefile(imgLuna[ZI], COORD1(pozLuna));
  1343. readimagefile(imgSoare[NOAPTE], COORD1(pozSoare));
  1344. break;
  1345. }
  1346. }
  1347. }
  1348. }
  1349. // buton ro
  1350. else if(esteDeasupra(x,y,pozRo) && limba == EN)
  1351. {
  1352. if(mod_sfx == PORNIT) sunetHover.play();
  1353.  
  1354. readimagefile(imgRo[mod][(limba+1)%2], COORD1(pozRo));
  1355. readimagefile(imgEn[mod][(limba+1)%2], COORD1(pozEn));
  1356.  
  1357. while(true)
  1358. {
  1359. if(ismouseclick(WM_LBUTTONDOWN))
  1360. {
  1361. clearmouseclick(WM_LBUTTONDOWN);
  1362. if(mod_sfx == PORNIT) sunetInainte.play();
  1363.  
  1364. limba = RO;
  1365. Meniu();
  1366. return;
  1367. }
  1368. if(ismouseclick(WM_MOUSEMOVE))
  1369. {
  1370. clearmouseclick(WM_MOUSEMOVE);
  1371. x = mousex();
  1372. y = mousey();
  1373.  
  1374. if(!esteDeasupra(x,y,pozRo))
  1375. {
  1376. readimagefile(imgRo[mod][limba], COORD1(pozRo));
  1377. readimagefile(imgEn[mod][limba], COORD1(pozEn));
  1378. break;
  1379. }
  1380. }
  1381. }
  1382. }
  1383. // buton en
  1384. else if(esteDeasupra(x,y,pozEn) && limba == RO)
  1385. {
  1386. if(mod_sfx == PORNIT) sunetHover.play();
  1387.  
  1388. readimagefile(imgEn[mod][(limba+1)%2], COORD1(pozEn));
  1389. readimagefile(imgRo[mod][(limba+1)%2], COORD1(pozRo));
  1390.  
  1391. while(true)
  1392. {
  1393. if(ismouseclick(WM_LBUTTONDOWN))
  1394. {
  1395. if(mod_sfx == PORNIT) sunetInainte.play();
  1396. clearmouseclick(WM_LBUTTONDOWN);
  1397.  
  1398. limba = EN;
  1399. Meniu();
  1400. return;
  1401. }
  1402. if(ismouseclick(WM_MOUSEMOVE))
  1403. {
  1404. clearmouseclick(WM_MOUSEMOVE);
  1405. x = mousex();
  1406. y = mousey();
  1407.  
  1408. if(!esteDeasupra(x,y,pozEn))
  1409. {
  1410. readimagefile(imgEn[mod][limba], COORD1(pozEn));
  1411. readimagefile(imgRo[mod][limba], COORD1(pozRo));
  1412. break;
  1413. }
  1414. }
  1415. }
  1416. }
  1417. }
  1418. }
  1419.  
  1420. void JocNou()
  1421. {
  1422. setfillstyle(SOLID_FILL, fundal);
  1423. bar(0,0,LUNGIME,LATIME);
  1424.  
  1425. fundal == WHITE ? setcolor(BLACK):setcolor(WHITE);
  1426. setbkcolor(fundal);
  1427. settextjustify(CENTER_TEXT, CENTER_TEXT);
  1428. settextstyle(3,0,4);
  1429.  
  1430. // butoane muzica + inapoi
  1431. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1432. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1433. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  1434.  
  1435. // butoane meniu
  1436. readimagefile(imgPVP[mod][limba], COORD1(pozPVP));
  1437. readimagefile(imgPVIA[mod][limba], COORD1(pozPVIA));
  1438. readimagefile(imgReluare[mod][limba], COORD1(pozReluare));
  1439.  
  1440. readimagefile(imgOptiuni[mod][limba], COORD1(pozOptiuni));
  1441.  
  1442. char s1[12], s2[12], s3[12];
  1443. itoa(nr_mutari, s1); itoa(nr_timp, s2); itoa(nr_safe, s3);
  1444.  
  1445. readimagefile(imgSageataL[mod], COORD1(pozS1a));
  1446. outtextxy(COORD2(pozS1), s1);
  1447. readimagefile(imgSageataR[mod], COORD1(pozS1b));
  1448.  
  1449. readimagefile(imgSageataL[mod], COORD1(pozS2a));
  1450. outtextxy(COORD2(pozS2), s2);
  1451. readimagefile(imgSageataR[mod], COORD1(pozS2b));
  1452.  
  1453. readimagefile(imgSageataL[mod], COORD1(pozS3a));
  1454. outtextxy(COORD2(pozS3), s3);
  1455. readimagefile(imgSageataR[mod], COORD1(pozS3b));
  1456.  
  1457. while(true)
  1458. {
  1459. clearmouseclick(WM_LBUTTONDOWN);
  1460. clearmouseclick(WM_MOUSEMOVE);
  1461.  
  1462. clearmouseclick(WM_MOUSEMOVE);
  1463. int x = mousex();
  1464. int y = mousey();
  1465.  
  1466. // buton muzica
  1467. if(esteDeasupra(x,y,pozMuzica))
  1468. {
  1469. while(true)
  1470. {
  1471. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1472. {
  1473. clearmouseclick(WM_LBUTTONDOWN);
  1474. clearmouseclick(WM_LBUTTONDBLCLK);
  1475. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  1476. {
  1477. muzicaFundal.stop();
  1478. mod_muzica = OPRIT;
  1479. }
  1480. else
  1481. {
  1482. muzicaFundal.play();
  1483. mod_muzica = PORNIT;
  1484. }
  1485.  
  1486. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1487. }
  1488. if(ismouseclick(WM_MOUSEMOVE))
  1489. {
  1490. clearmouseclick(WM_MOUSEMOVE);
  1491. x = mousex();
  1492. y = mousey();
  1493.  
  1494. if(!esteDeasupra(x,y,pozMuzica)) break;
  1495. }
  1496. }
  1497. }
  1498. // buton sfx
  1499. else if(esteDeasupra(x,y,pozSfx))
  1500. {
  1501. while(true)
  1502. {
  1503. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1504. {
  1505. clearmouseclick(WM_LBUTTONDOWN);
  1506. clearmouseclick(WM_LBUTTONDBLCLK);
  1507. mod_sfx = (mod_sfx+1) % 2;
  1508.  
  1509. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1510. }
  1511. if(ismouseclick(WM_MOUSEMOVE))
  1512. {
  1513. clearmouseclick(WM_MOUSEMOVE);
  1514. x = mousex();
  1515. y = mousey();
  1516.  
  1517. if(!esteDeasupra(x,y,pozSfx)) break;
  1518. }
  1519. }
  1520. }
  1521. // buton inapoi
  1522. else if(esteDeasupra(x,y,pozInapoi))
  1523. {
  1524. if(mod_sfx == PORNIT) sunetHover.play();
  1525. readimagefile(imgInapoi[(mod+1)%2], COORD1(pozInapoi));
  1526.  
  1527. while(true)
  1528. {
  1529. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1530. {
  1531. clearmouseclick(WM_LBUTTONDOWN);
  1532. clearmouseclick(WM_LBUTTONDBLCLK);
  1533. if(mod_sfx == PORNIT) sunetInapoi.play();
  1534. Meniu();
  1535. return;
  1536. }
  1537. if(ismouseclick(WM_MOUSEMOVE))
  1538. {
  1539. clearmouseclick(WM_MOUSEMOVE);
  1540. x = mousex();
  1541. y = mousey();
  1542.  
  1543. if(!esteDeasupra(x,y,pozInapoi))
  1544. {
  1545. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  1546. break;
  1547. }
  1548. }
  1549. }
  1550. }
  1551. // buton player vs player
  1552. else if(esteDeasupra(x,y,pozPVP))
  1553. {
  1554. if(mod_sfx == PORNIT) sunetHover.play();
  1555. readimagefile(imgPVP[(mod+1)%2][limba], COORD1(pozPVP));
  1556.  
  1557. bar(STERGE(pozOm));
  1558. readimagefile(imgOm[mod], COORD1(pozOm));
  1559.  
  1560. while(true)
  1561. {
  1562. if(ismouseclick(WM_LBUTTONDOWN))
  1563. {
  1564. clearmouseclick(WM_LBUTTONDOWN);
  1565. if(mod_sfx == PORNIT) sunetInainte.play();
  1566.  
  1567. // schimba melodia
  1568. if(mod_muzica == PORNIT)
  1569. {
  1570. muzicaFundal.stop();
  1571. muzicaFundal.openFromFile("audio/ingame.wav"); muzicaFundal.setVolume(50.f);
  1572. muzicaFundal.play();
  1573. }
  1574. PVP();
  1575. return;
  1576. }
  1577. if(ismouseclick(WM_MOUSEMOVE))
  1578. {
  1579. clearmouseclick(WM_MOUSEMOVE);
  1580. x = mousex();
  1581. y = mousey();
  1582.  
  1583. if(!esteDeasupra(x,y,pozPVP))
  1584. {
  1585. readimagefile(imgPVP[mod][limba], COORD1(pozPVP));
  1586. bar(STERGE(pozOm));
  1587. break;
  1588. }
  1589. }
  1590. }
  1591. }
  1592. // buton player vs ia
  1593. else if(esteDeasupra(x,y,pozPVIA))
  1594. {
  1595. if(mod_sfx == PORNIT) sunetHover.play();
  1596.  
  1597. readimagefile(imgPVIA[(mod+1)%2][limba], COORD1(pozPVIA));
  1598.  
  1599. bar(STERGE(pozOchi));
  1600. readimagefile(imgOchi[mod], COORD1(pozOchi));
  1601.  
  1602. while(true)
  1603. {
  1604. if(ismouseclick(WM_LBUTTONDOWN))
  1605. {
  1606. clearmouseclick(WM_LBUTTONDOWN);
  1607. if(mod_sfx == PORNIT) if(mod_sfx == PORNIT) sunetInainte.play();
  1608. PVIA();
  1609. return;
  1610. }
  1611. if(ismouseclick(WM_MOUSEMOVE))
  1612. {
  1613. clearmouseclick(WM_MOUSEMOVE);
  1614. x = mousex();
  1615. y = mousey();
  1616.  
  1617. if(!esteDeasupra(x,y,pozPVIA))
  1618. {
  1619. readimagefile(imgPVIA[mod][limba], COORD1(pozPVIA));
  1620. bar(STERGE(pozOchi));
  1621. break;
  1622. }
  1623. }
  1624. }
  1625. }
  1626. // buton replay
  1627. else if(esteDeasupra(x,y,pozReluare))
  1628. {
  1629. if(mod_sfx == PORNIT) sunetHover.play();
  1630.  
  1631. readimagefile(imgReluare[(mod+1)%2][limba], COORD1(pozReluare));
  1632.  
  1633. bar(STERGE(pozRotita));
  1634. readimagefile(imgReplay[mod], COORD1(pozReplay));
  1635.  
  1636. while(true)
  1637. {
  1638. if(ismouseclick(WM_LBUTTONDOWN))
  1639. {
  1640. clearmouseclick(WM_LBUTTONDOWN);
  1641. if(mod_sfx == PORNIT) if(mod_sfx == PORNIT) sunetInainte.play();
  1642. Reluare();
  1643. return;
  1644. }
  1645. if(ismouseclick(WM_MOUSEMOVE))
  1646. {
  1647. clearmouseclick(WM_MOUSEMOVE);
  1648. x = mousex();
  1649. y = mousey();
  1650.  
  1651. if(!esteDeasupra(x,y,pozReluare))
  1652. {
  1653. readimagefile(imgReluare[mod][limba], COORD1(pozReluare));
  1654. bar(STERGE(pozReplay));
  1655. break;
  1656. }
  1657. }
  1658. }
  1659. }
  1660. // buton <nr_mutari> stanga
  1661. else if(esteDeasupra(x,y,pozS1a))
  1662. {
  1663. if(mod_sfx == PORNIT) sunetHover.play();
  1664.  
  1665. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozS1a));
  1666.  
  1667. while(true)
  1668. {
  1669. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1670. {
  1671. clearmouseclick(WM_LBUTTONDOWN);
  1672. clearmouseclick(WM_LBUTTONDBLCLK);
  1673. if(mod_sfx == PORNIT) sunetSchimba.play();
  1674.  
  1675. bar(pozS1[0]-36, pozS1[1]-36, pozS1[0]+36, pozS1[1]+36);
  1676.  
  1677. nr_mutari -= 10; // din 10 in 10
  1678. if(nr_mutari == 0) nr_mutari = 100; // [10, 100]
  1679.  
  1680. itoa(nr_mutari, s1);
  1681. outtextxy(COORD2(pozS1), s1);
  1682. }
  1683. if(ismouseclick(WM_MOUSEMOVE))
  1684. {
  1685. clearmouseclick(WM_MOUSEMOVE);
  1686. x = mousex();
  1687. y = mousey();
  1688.  
  1689. if(!esteDeasupra(x,y,pozS1a))
  1690. {
  1691. readimagefile(imgSageataL[mod], COORD1(pozS1a));
  1692. break;
  1693. }
  1694. }
  1695. }
  1696. }
  1697. // buton <nr_mutari> dreapta
  1698. else if(esteDeasupra(x,y,pozS1b))
  1699. {
  1700. if(mod_sfx == PORNIT) sunetHover.play();
  1701.  
  1702. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozS1b));
  1703.  
  1704. while(true)
  1705. {
  1706. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1707. {
  1708. clearmouseclick(WM_LBUTTONDOWN);
  1709. clearmouseclick(WM_LBUTTONDBLCLK);
  1710. if(mod_sfx == PORNIT) sunetSchimba.play();
  1711.  
  1712. bar(pozS1[0]-36, pozS1[1]-36, pozS1[0]+36, pozS1[1]+36);
  1713.  
  1714. nr_mutari += 10;
  1715. if(nr_mutari == 110) nr_mutari = 10;
  1716.  
  1717. itoa(nr_mutari, s1);
  1718. outtextxy(COORD2(pozS1), s1);
  1719. }
  1720. if(ismouseclick(WM_MOUSEMOVE))
  1721. {
  1722. clearmouseclick(WM_MOUSEMOVE);
  1723. x = mousex();
  1724. y = mousey();
  1725.  
  1726. if(!esteDeasupra(x,y,pozS1b))
  1727. {
  1728. readimagefile(imgSageataR[mod], COORD1(pozS1b));
  1729. break;
  1730. }
  1731. }
  1732. }
  1733. }
  1734. // buton <nr_timp> stanga
  1735. else if(esteDeasupra(x,y,pozS2a))
  1736. {
  1737. if(mod_sfx == PORNIT) sunetHover.play();
  1738.  
  1739. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozS2a));
  1740.  
  1741. while(true)
  1742. {
  1743. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1744. {
  1745. clearmouseclick(WM_LBUTTONDOWN);
  1746. clearmouseclick(WM_LBUTTONDBLCLK);
  1747. if(mod_sfx == PORNIT) sunetSchimba.play();
  1748.  
  1749. bar(pozS2[0]-36, pozS2[1]-36, pozS2[0]+36, pozS2[1]+36);
  1750.  
  1751. nr_timp--;
  1752. if(nr_timp == 0) nr_timp = 15;
  1753.  
  1754. itoa(nr_timp, s2);
  1755. outtextxy(COORD2(pozS2), s2);
  1756. }
  1757. if(ismouseclick(WM_MOUSEMOVE))
  1758. {
  1759. clearmouseclick(WM_MOUSEMOVE);
  1760. x = mousex();
  1761. y = mousey();
  1762.  
  1763. if(!esteDeasupra(x,y,pozS2a))
  1764. {
  1765. readimagefile(imgSageataL[mod], COORD1(pozS2a));
  1766. break;
  1767. }
  1768. }
  1769. }
  1770. }
  1771. // buton <nr_timp> dreapta
  1772. else if(esteDeasupra(x,y,pozS2b))
  1773. {
  1774. if(mod_sfx == PORNIT) sunetHover.play();
  1775.  
  1776. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozS2b));
  1777.  
  1778. while(true)
  1779. {
  1780. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1781. {
  1782. clearmouseclick(WM_LBUTTONDOWN);
  1783. clearmouseclick(WM_LBUTTONDBLCLK);
  1784. if(mod_sfx == PORNIT) sunetSchimba.play();
  1785.  
  1786. bar(pozS2[0]-36, pozS2[1]-36, pozS2[0]+36, pozS2[1]+36);
  1787.  
  1788. nr_timp++;
  1789. if(nr_timp == 16) nr_timp = 1;
  1790.  
  1791. itoa(nr_timp, s2);
  1792. outtextxy(COORD2(pozS2), s2);
  1793. }
  1794. if(ismouseclick(WM_MOUSEMOVE))
  1795. {
  1796. clearmouseclick(WM_MOUSEMOVE);
  1797. x = mousex();
  1798. y = mousey();
  1799.  
  1800. if(!esteDeasupra(x,y,pozS2b))
  1801. {
  1802. readimagefile(imgSageataR[mod], COORD1(pozS2b));
  1803. break;
  1804. }
  1805. }
  1806. }
  1807. }
  1808. // buton <nr_safe> stanga
  1809. else if(esteDeasupra(x,y,pozS3a))
  1810. {
  1811. if(mod_sfx == PORNIT) sunetHover.play();
  1812.  
  1813. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozS3a));
  1814.  
  1815. while(true)
  1816. {
  1817. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1818. {
  1819. clearmouseclick(WM_LBUTTONDOWN);
  1820. clearmouseclick(WM_LBUTTONDBLCLK);
  1821. if(mod_sfx == PORNIT) sunetSchimba.play();
  1822.  
  1823. bar(pozS3[0]-36, pozS3[1]-36, pozS3[0]+36, pozS3[1]+36);
  1824.  
  1825. nr_safe -= 2;
  1826. if(nr_safe == -2) nr_safe = 10;
  1827.  
  1828. itoa(nr_safe, s3);
  1829. outtextxy(COORD2(pozS3), s3);
  1830. }
  1831. if(ismouseclick(WM_MOUSEMOVE))
  1832. {
  1833. clearmouseclick(WM_MOUSEMOVE);
  1834. x = mousex();
  1835. y = mousey();
  1836.  
  1837. if(!esteDeasupra(x,y,pozS3a))
  1838. {
  1839. readimagefile(imgSageataL[mod], COORD1(pozS3a));
  1840. break;
  1841. }
  1842. }
  1843. }
  1844. }
  1845. // buton <nr_safe> dreapta
  1846. else if(esteDeasupra(x,y,pozS3b))
  1847. {
  1848. if(mod_sfx == PORNIT) sunetHover.play();
  1849.  
  1850. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozS3b));
  1851.  
  1852. while(true)
  1853. {
  1854. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1855. {
  1856. clearmouseclick(WM_LBUTTONDOWN);
  1857. clearmouseclick(WM_LBUTTONDBLCLK);
  1858. if(mod_sfx == PORNIT) sunetSchimba.play();
  1859.  
  1860. bar(pozS3[0]-36, pozS3[1]-36, pozS3[0]+36, pozS3[1]+36);
  1861.  
  1862. nr_safe += 2;
  1863. if(nr_safe == 12) nr_safe = 0;
  1864.  
  1865. itoa(nr_safe, s3);
  1866. outtextxy(COORD2(pozS3), s3);
  1867. }
  1868. if(ismouseclick(WM_MOUSEMOVE))
  1869. {
  1870. clearmouseclick(WM_MOUSEMOVE);
  1871. x = mousex();
  1872. y = mousey();
  1873.  
  1874. if(!esteDeasupra(x,y,pozS3b))
  1875. {
  1876. readimagefile(imgSageataR[mod], COORD1(pozS3b));
  1877. break;
  1878. }
  1879. }
  1880. }
  1881. }
  1882. }
  1883. }
  1884.  
  1885. void Tutorial()
  1886. {
  1887. //imagini butoane
  1888. setfillstyle(SOLID_FILL, fundal);
  1889. bar(0,0,LUNGIME,LATIME);
  1890.  
  1891. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1892. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1893. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  1894.  
  1895. const char imgCartoi[2][LEN] = {"img/cartoiD.jpg", "img/cartoiN.jpg"};
  1896. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  1897.  
  1898. readimagefile(imgTut1[mod][limba], COORD1(pozTut1));
  1899. readimagefile(imgTut2[mod][limba], COORD1(pozTut2));
  1900. readimagefile(imgTut3[mod][limba], COORD1(pozTut3));
  1901. readimagefile(imgTut4[mod][limba], COORD1(pozTut4));
  1902. readimagefile(imgTut5[mod][limba], COORD1(pozTut5));
  1903.  
  1904. while(true)
  1905. {
  1906. clearmouseclick(WM_LBUTTONDOWN);
  1907. clearmouseclick(WM_MOUSEMOVE);
  1908.  
  1909. int x = mousex();
  1910. int y = mousey();
  1911.  
  1912. // buton muzica
  1913. if(esteDeasupra(x,y,pozMuzica))
  1914. {
  1915. while(true)
  1916. {
  1917. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1918. {
  1919. clearmouseclick(WM_LBUTTONDOWN);
  1920. clearmouseclick(WM_LBUTTONDBLCLK);
  1921. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  1922. {
  1923. muzicaFundal.stop();
  1924. mod_muzica = OPRIT;
  1925. }
  1926. else
  1927. {
  1928. muzicaFundal.play();
  1929. mod_muzica = PORNIT;
  1930. }
  1931.  
  1932. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  1933. }
  1934. if(ismouseclick(WM_MOUSEMOVE))
  1935. {
  1936. clearmouseclick(WM_MOUSEMOVE);
  1937. x = mousex();
  1938. y = mousey();
  1939.  
  1940. if(!esteDeasupra(x,y,pozMuzica)) break;
  1941. }
  1942. }
  1943. }
  1944. // buton sfx
  1945. else if(esteDeasupra(x,y,pozSfx))
  1946. {
  1947. while(true)
  1948. {
  1949. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1950. {
  1951. clearmouseclick(WM_LBUTTONDOWN);
  1952. clearmouseclick(WM_LBUTTONDBLCLK);
  1953. mod_sfx = (mod_sfx+1) % 2;
  1954.  
  1955. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  1956. }
  1957. if(ismouseclick(WM_MOUSEMOVE))
  1958. {
  1959. clearmouseclick(WM_MOUSEMOVE);
  1960. x = mousex();
  1961. y = mousey();
  1962.  
  1963. if(!esteDeasupra(x,y,pozSfx)) break;
  1964. }
  1965. }
  1966. }
  1967. // buton inapoi
  1968. else if(esteDeasupra(x,y,pozInapoi))
  1969. {
  1970. if(mod_sfx == PORNIT) sunetHover.play();
  1971. readimagefile(imgInapoi[(mod+1)%2], COORD1(pozInapoi));
  1972.  
  1973. while(true)
  1974. {
  1975. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  1976. {
  1977. clearmouseclick(WM_LBUTTONDOWN);
  1978. clearmouseclick(WM_LBUTTONDBLCLK);
  1979. if(mod_sfx == PORNIT) sunetInapoi.play();
  1980. Meniu();
  1981. return;
  1982. }
  1983. if(ismouseclick(WM_MOUSEMOVE))
  1984. {
  1985. clearmouseclick(WM_MOUSEMOVE);
  1986. x = mousex();
  1987. y = mousey();
  1988.  
  1989. if(!esteDeasupra(x,y,pozInapoi))
  1990. {
  1991. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  1992. break;
  1993. }
  1994. }
  1995. }
  1996. }
  1997. // prezentare
  1998. else if(esteDeasupra(x,y,pozTut1))
  1999. {
  2000. if(mod_sfx == PORNIT) sunetHover.play();
  2001. readimagefile(imgTut1[(mod+1)%2][limba], COORD1(pozTut1));
  2002. readimagefile(imgGhid1[mod][limba],COORD1(pozGhid));
  2003. while(true)
  2004. {
  2005. clearmouseclick(WM_MOUSEMOVE);
  2006. int x = mousex();
  2007. int y = mousey();
  2008. if(!esteDeasupra(x,y,pozTut1))
  2009. {
  2010. readimagefile(imgTut1[mod][limba], COORD1(pozTut1));
  2011. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  2012.  
  2013. break;
  2014. }
  2015. }
  2016. }
  2017. // mutarea
  2018. else if(esteDeasupra(x,y,pozTut2))
  2019. {
  2020. if(mod_sfx == PORNIT) sunetHover.play();
  2021. readimagefile(imgTut2[(mod+1)%2][limba], COORD1(pozTut2));
  2022. readimagefile(imgGhid2[mod][limba],COORD1(pozGhid));
  2023. while(true)
  2024. {
  2025. clearmouseclick(WM_MOUSEMOVE);
  2026. int x = mousex();
  2027. int y = mousey();
  2028. if(!esteDeasupra(x,y,pozTut2))
  2029. {
  2030. readimagefile(imgTut2[mod][limba], COORD1(pozTut2));
  2031. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  2032.  
  2033. break;
  2034. }
  2035. }
  2036. }
  2037. // blocarea
  2038. else if(esteDeasupra(x,y,pozTut3))
  2039. {
  2040. if(mod_sfx == PORNIT) sunetHover.play();
  2041. readimagefile(imgTut3[(mod+1)%2][limba], COORD1(pozTut3));
  2042. readimagefile(imgGhid3[mod][limba],COORD1(pozGhid));
  2043. while(true)
  2044. {
  2045. clearmouseclick(WM_MOUSEMOVE);
  2046. int x = mousex();
  2047. int y = mousey();
  2048. if(!esteDeasupra(x,y,pozTut3))
  2049. {
  2050. readimagefile(imgTut3[mod][limba], COORD1(pozTut3));
  2051. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  2052.  
  2053. break;
  2054. }
  2055. }
  2056. }
  2057. // limitari
  2058. else if(esteDeasupra(x,y,pozTut4))
  2059. {
  2060. if(mod_sfx == PORNIT) sunetHover.play();
  2061. readimagefile(imgTut4[(mod+1)%2][limba], COORD1(pozTut4));
  2062. readimagefile(imgGhid4[mod][limba],COORD1(pozGhid));
  2063. while(true)
  2064. {
  2065. clearmouseclick(WM_MOUSEMOVE);
  2066. int x = mousex();
  2067. int y = mousey();
  2068. if(!esteDeasupra(x,y,pozTut4))
  2069. {
  2070. readimagefile(imgTut4[mod][limba], COORD1(pozTut4));
  2071. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  2072.  
  2073. break;
  2074. }
  2075. }
  2076. }
  2077. // replay
  2078. else if(esteDeasupra(x,y,pozTut5))
  2079. {
  2080. if(mod_sfx == PORNIT) sunetHover.play();
  2081. readimagefile(imgTut5[(mod+1)%2][limba], COORD1(pozTut5));
  2082. readimagefile(imgGhid5[mod][limba],COORD1(pozGhid));
  2083. while(true)
  2084. {
  2085. clearmouseclick(WM_MOUSEMOVE);
  2086. int x = mousex();
  2087. int y = mousey();
  2088. if(!esteDeasupra(x,y,pozTut5))
  2089. {
  2090. readimagefile(imgTut5[mod][limba], COORD1(pozTut5));
  2091. readimagefile(imgCartoi[mod], COORD1(pozGhid));
  2092.  
  2093. break;
  2094. }
  2095. }
  2096. }
  2097. }
  2098. }
  2099.  
  2100. void Setari()
  2101. {
  2102. setfillstyle(SOLID_FILL, fundal);
  2103. bar(0,0,LUNGIME,LATIME);
  2104.  
  2105. fundal == WHITE ? setcolor(BLACK):setcolor(WHITE);
  2106. setbkcolor(fundal);
  2107.  
  2108. settextjustify(CENTER_TEXT, CENTER_TEXT);
  2109. settextstyle(3,0,4);
  2110.  
  2111. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2112. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2113. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2114.  
  2115. readimagefile(imgAspect[mod][limba], COORD1(pozAspect));
  2116.  
  2117. readimagefile(imgSageataL[mod], COORD1(pozA1a));
  2118. readimagefile(imgPiesaA[aspect_j1], COORD1(pozA1));
  2119. readimagefile(imgSageataR[mod], COORD1(pozA1b));
  2120.  
  2121. readimagefile(imgSageataL[mod], COORD1(pozA2a));
  2122. readimagefile(imgPiesaB[aspect_j2], COORD1(pozA2));
  2123. readimagefile(imgSageataR[mod], COORD1(pozA2b));
  2124.  
  2125. readimagefile(imgSageataL[mod], COORD1(pozA3a));
  2126. readimagefile(imgTabla[1][aspect_tabla], COORD1(pozA3));
  2127. readimagefile(imgSageataR[mod], COORD1(pozA3b));
  2128.  
  2129. while(true)
  2130. {
  2131. clearmouseclick(WM_LBUTTONDOWN);
  2132. clearmouseclick(WM_MOUSEMOVE);
  2133.  
  2134. int x = mousex();
  2135. int y = mousey();
  2136.  
  2137. // buton muzica
  2138. if(esteDeasupra(x,y,pozMuzica))
  2139. {
  2140. while(true)
  2141. {
  2142. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2143. {
  2144. clearmouseclick(WM_LBUTTONDOWN);
  2145. clearmouseclick(WM_LBUTTONDBLCLK);
  2146. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  2147. {
  2148. muzicaFundal.stop();
  2149. mod_muzica = OPRIT;
  2150. }
  2151. else
  2152. {
  2153. muzicaFundal.play();
  2154. mod_muzica = PORNIT;
  2155. }
  2156.  
  2157. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2158. }
  2159. if(ismouseclick(WM_MOUSEMOVE))
  2160. {
  2161. clearmouseclick(WM_MOUSEMOVE);
  2162. x = mousex();
  2163. y = mousey();
  2164.  
  2165. if(!esteDeasupra(x,y,pozMuzica)) break;
  2166. }
  2167. }
  2168. }
  2169. // buton sfx
  2170. else if(esteDeasupra(x,y,pozSfx))
  2171. {
  2172. while(true)
  2173. {
  2174. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2175. {
  2176. clearmouseclick(WM_LBUTTONDOWN);
  2177. clearmouseclick(WM_LBUTTONDBLCLK);
  2178. mod_sfx = (mod_sfx+1) % 2;
  2179.  
  2180. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2181. }
  2182. if(ismouseclick(WM_MOUSEMOVE))
  2183. {
  2184. clearmouseclick(WM_MOUSEMOVE);
  2185. x = mousex();
  2186. y = mousey();
  2187.  
  2188. if(!esteDeasupra(x,y,pozSfx)) break;
  2189. }
  2190. }
  2191. }
  2192. // buton inapoi
  2193. else if(esteDeasupra(x,y,pozInapoi))
  2194. {
  2195. if(mod_sfx == PORNIT) sunetHover.play();
  2196. readimagefile(imgInapoi[(mod+1)%2], COORD1(pozInapoi));
  2197.  
  2198. while(true)
  2199. {
  2200. if(ismouseclick(WM_LBUTTONDOWN))
  2201. {
  2202. clearmouseclick(WM_LBUTTONDOWN);
  2203. if(mod_sfx == PORNIT) sunetInapoi.play();
  2204. Meniu();
  2205. return;
  2206. }
  2207. if(ismouseclick(WM_MOUSEMOVE))
  2208. {
  2209. clearmouseclick(WM_MOUSEMOVE);
  2210. x = mousex();
  2211. y = mousey();
  2212.  
  2213. if(!esteDeasupra(x,y,pozInapoi))
  2214. {
  2215. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2216. break;
  2217. }
  2218. }
  2219. }
  2220. }
  2221. // buton <jucator1> stanga
  2222. else if(esteDeasupra(x,y,pozA1a))
  2223. {
  2224. if(mod_sfx == PORNIT) sunetHover.play();
  2225.  
  2226. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozA1a));
  2227.  
  2228. while(true)
  2229. {
  2230. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2231. {
  2232. clearmouseclick(WM_LBUTTONDOWN);
  2233. clearmouseclick(WM_LBUTTONDBLCLK);
  2234. if(mod_sfx == PORNIT) sunetSchimba.play();
  2235.  
  2236. aspect_j1 = (aspect_j1-1+3) % 3;
  2237. readimagefile(imgPiesaA[aspect_j1], COORD1(pozA1));
  2238. }
  2239. if(ismouseclick(WM_MOUSEMOVE))
  2240. {
  2241. clearmouseclick(WM_MOUSEMOVE);
  2242. x = mousex();
  2243. y = mousey();
  2244.  
  2245. if(!esteDeasupra(x,y,pozA1a))
  2246. {
  2247. readimagefile(imgSageataL[mod], COORD1(pozA1a));
  2248. break;
  2249. }
  2250. }
  2251. }
  2252. }
  2253. // buton <jucator1> dreapta
  2254. else if(esteDeasupra(x,y,pozA1b))
  2255. {
  2256. if(mod_sfx == PORNIT) sunetHover.play();
  2257.  
  2258. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozA1b));
  2259.  
  2260. while(true)
  2261. {
  2262. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2263. {
  2264. clearmouseclick(WM_LBUTTONDOWN);
  2265. clearmouseclick(WM_LBUTTONDBLCLK);
  2266. if(mod_sfx == PORNIT) sunetSchimba.play();
  2267.  
  2268. aspect_j1 = (aspect_j1+1) % 3;
  2269. readimagefile(imgPiesaA[aspect_j1], COORD1(pozA1));
  2270. }
  2271. if(ismouseclick(WM_MOUSEMOVE))
  2272. {
  2273. clearmouseclick(WM_MOUSEMOVE);
  2274. x = mousex();
  2275. y = mousey();
  2276.  
  2277. if(!esteDeasupra(x,y,pozA1b))
  2278. {
  2279. readimagefile(imgSageataR[mod], COORD1(pozA1b));
  2280. break;
  2281. }
  2282. }
  2283. }
  2284. }
  2285. // buton <jucator2> stanga
  2286. else if(esteDeasupra(x,y,pozA2a))
  2287. {
  2288. if(mod_sfx == PORNIT) sunetHover.play();
  2289.  
  2290. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozA2a));
  2291.  
  2292. while(true)
  2293. {
  2294. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2295. {
  2296. clearmouseclick(WM_LBUTTONDOWN);
  2297. clearmouseclick(WM_LBUTTONDBLCLK);
  2298. if(mod_sfx == PORNIT) sunetSchimba.play();
  2299.  
  2300. aspect_j2 = (aspect_j2-1+3) % 3;
  2301. readimagefile(imgPiesaB[aspect_j2], COORD1(pozA2));
  2302. }
  2303. if(ismouseclick(WM_MOUSEMOVE))
  2304. {
  2305. clearmouseclick(WM_MOUSEMOVE);
  2306. x = mousex();
  2307. y = mousey();
  2308.  
  2309. if(!esteDeasupra(x,y,pozA2a))
  2310. {
  2311. readimagefile(imgSageataL[mod], COORD1(pozA2a));
  2312. break;
  2313. }
  2314. }
  2315. }
  2316. }
  2317. // buton <jucator2> dreapta
  2318. else if(esteDeasupra(x,y,pozA2b))
  2319. {
  2320. if(mod_sfx == PORNIT) sunetHover.play();
  2321.  
  2322. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozA2b));
  2323.  
  2324. while(true)
  2325. {
  2326. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2327. {
  2328. clearmouseclick(WM_LBUTTONDOWN);
  2329. clearmouseclick(WM_LBUTTONDBLCLK);
  2330. if(mod_sfx == PORNIT) sunetSchimba.play();
  2331.  
  2332. aspect_j2 = (aspect_j2+1) % 3;
  2333. readimagefile(imgPiesaB[aspect_j2], COORD1(pozA2));
  2334. }
  2335. if(ismouseclick(WM_MOUSEMOVE))
  2336. {
  2337. clearmouseclick(WM_MOUSEMOVE);
  2338. x = mousex();
  2339. y = mousey();
  2340.  
  2341. if(!esteDeasupra(x,y,pozA2b))
  2342. {
  2343. readimagefile(imgSageataR[mod], COORD1(pozA2b));
  2344. break;
  2345. }
  2346. }
  2347. }
  2348. }
  2349. // buton <tabla> stanga
  2350. else if(esteDeasupra(x,y,pozA3a))
  2351. {
  2352. if(mod_sfx == PORNIT) sunetHover.play();
  2353.  
  2354. readimagefile(imgSageataL[(mod+1)%2], COORD1(pozA3a));
  2355.  
  2356. while(true)
  2357. {
  2358. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2359. {
  2360. clearmouseclick(WM_LBUTTONDOWN);
  2361. clearmouseclick(WM_LBUTTONDBLCLK);
  2362. if(mod_sfx == PORNIT) sunetSchimba.play();
  2363.  
  2364. aspect_tabla = (aspect_tabla-1 + 3) % 3;
  2365. readimagefile(imgTabla[1][aspect_tabla], COORD1(pozA3));
  2366. }
  2367. if(ismouseclick(WM_MOUSEMOVE))
  2368. {
  2369. clearmouseclick(WM_MOUSEMOVE);
  2370. x = mousex();
  2371. y = mousey();
  2372.  
  2373. if(!esteDeasupra(x,y,pozA3a))
  2374. {
  2375. readimagefile(imgSageataL[mod], COORD1(pozA3a));
  2376. break;
  2377. }
  2378. }
  2379. }
  2380. }
  2381. // buton <tabla> dreapta
  2382. else if(esteDeasupra(x,y,pozA3b))
  2383. {
  2384. if(mod_sfx == PORNIT) sunetHover.play();
  2385.  
  2386. readimagefile(imgSageataR[(mod+1)%2], COORD1(pozA3b));
  2387.  
  2388. while(true)
  2389. {
  2390. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2391. {
  2392. clearmouseclick(WM_LBUTTONDOWN);
  2393. clearmouseclick(WM_LBUTTONDBLCLK);
  2394. if(mod_sfx == PORNIT) sunetSchimba.play();
  2395.  
  2396. aspect_tabla = (aspect_tabla+1) % 3;
  2397. readimagefile(imgTabla[1][aspect_tabla], COORD1(pozA3));
  2398. }
  2399. if(ismouseclick(WM_MOUSEMOVE))
  2400. {
  2401. clearmouseclick(WM_MOUSEMOVE);
  2402. x = mousex();
  2403. y = mousey();
  2404.  
  2405. if(!esteDeasupra(x,y,pozA3b))
  2406. {
  2407. readimagefile(imgSageataR[mod], COORD1(pozA3b));
  2408. break;
  2409. }
  2410. }
  2411. }
  2412. }
  2413. }
  2414. }
  2415.  
  2416. void Credits()
  2417. {
  2418. setfillstyle(SOLID_FILL, fundal);
  2419. setcolor(fundal);
  2420. bar(0,0,LUNGIME,LATIME);
  2421.  
  2422. readimagefile(imgInfo[mod][limba], COORD1(pozInfo));
  2423. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2424.  
  2425. while(true)
  2426. {
  2427. clearmouseclick(WM_LBUTTONDOWN);
  2428. clearmouseclick(WM_MOUSEMOVE);
  2429.  
  2430. int x = mousex();
  2431. int y = mousey();
  2432.  
  2433. // buton inapoi
  2434. if(esteDeasupra(x,y,pozInapoi))
  2435. {
  2436. if(mod_sfx == PORNIT) sunetHover.play();
  2437. readimagefile(imgInapoi[(mod+1)%2], COORD1(pozInapoi));
  2438.  
  2439. while(true)
  2440. {
  2441. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2442. {
  2443. clearmouseclick(WM_LBUTTONDOWN);
  2444. clearmouseclick(WM_LBUTTONDBLCLK);
  2445. if(mod_sfx == PORNIT) sunetInapoi.play();
  2446. Meniu();
  2447. return;
  2448. }
  2449. if(ismouseclick(WM_MOUSEMOVE))
  2450. {
  2451. clearmouseclick(WM_MOUSEMOVE);
  2452. x = mousex();
  2453. y = mousey();
  2454.  
  2455. if(!esteDeasupra(x,y,pozInapoi))
  2456. {
  2457. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2458. break;
  2459. }
  2460. }
  2461. }
  2462. }
  2463. }
  2464. }
  2465.  
  2466. void PVP()
  2467. {
  2468. // initializeaza seed
  2469. srand(time(NULL));
  2470.  
  2471. // curata ecran
  2472. setfillstyle(SOLID_FILL, fundal);
  2473. bar(0,0,LUNGIME,LATIME);
  2474.  
  2475. // butoane muzica
  2476. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2477. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2478.  
  2479. // resetare text
  2480. strcpy(txt_infoP1[0],"randul tau"); strcpy(txt_infoP1[1],"your turn");
  2481. strcpy(txt_infoP2[0],"randul tau"); strcpy(txt_infoP2[1],"your turn");
  2482. strcpy(txt_infoMutari[0],"mutari ramase: "); strcpy(txt_infoMutari[1],"turns left: ");
  2483. strcpy(txt_infoTimer,"00:");
  2484.  
  2485. // informatii text
  2486. fundal == WHITE ? setcolor(BLACK):setcolor(WHITE);
  2487. setbkcolor(fundal);
  2488. settextjustify(CENTER_TEXT, CENTER_TEXT);
  2489.  
  2490. settextstyle(3,0,4);
  2491. readimagefile(imgPiesaA[aspect_j1], COORD1(pozPiesaA)); // tabela
  2492. outtextxy(COORD2(pozScor), "0 - 0"); // de
  2493. readimagefile(imgPiesaB[aspect_j2], COORD1(pozPiesaB)); // scor
  2494.  
  2495. char txtNrMutari[12]; itoa(nr_mutari, txtNrMutari);
  2496. char txtInfoMutari[LEN]; strcpy(txtInfoMutari, txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  2497. settextstyle(8,0,3);
  2498. outtextxy(COORD2(pozRamase), txtInfoMutari);
  2499.  
  2500. char txtTimp[12]; itoa(nr_timp, txtTimp);
  2501. if(nr_timp < 10) txtTimp[1] = txtTimp[0], txtTimp[0] = '0', txtTimp[2] = NULL;
  2502. char txtInfoTimer[LEN]; strcpy(txtInfoTimer, txt_infoTimer); strcat(txtInfoTimer,txtTimp);
  2503. settextstyle(3,0,8);
  2504. outtextxy(COORD2(pozTimer), txtInfoTimer); // timer
  2505.  
  2506. // istoric mutari
  2507. readimagefile(imgIstoric[mod], COORD1(pozIstoric));
  2508. pozMutare[0] = pozIstoric[limba][0]+12;
  2509. pozMutare[1] = pozIstoric[limba][1]+12;
  2510.  
  2511. // buton abandon
  2512. readimagefile(imgAbandon[mod][limba], COORD1(pozAbandon));
  2513.  
  2514. // joc
  2515. initializareTabla();
  2516.  
  2517. scor_j1 = scor_j2 = 0;
  2518. mutari_ramase = nr_mutari;
  2519. timp_limita = nr_timp;
  2520. timp_expirat = joc_terminat = false;
  2521.  
  2522. strcpy(txt_logs[0], "NULL");
  2523.  
  2524. settextstyle(8,0,2);
  2525. outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  2526.  
  2527. while(joc_terminat == false)
  2528. {
  2529. timp_limita = nr_timp;
  2530. mutarePiesa();
  2531. joc_terminat = verificaSfarsit();
  2532. }
  2533.  
  2534. scor_j1 == scor_j2 ? Sfarsit(2,0) : Sfarsit(1,0);
  2535. return;
  2536. }
  2537.  
  2538. void PVIA()
  2539. {
  2540. // initializeaza seed
  2541. srand(time(NULL));
  2542.  
  2543. // curata ecran
  2544. setfillstyle(SOLID_FILL, fundal);
  2545. bar(0,0,LUNGIME,LATIME);
  2546.  
  2547. // butoane muzica
  2548. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2549. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2550.  
  2551. // resetare text
  2552. strcpy(txt_infoP1[0],"randul tau"); strcpy(txt_infoP1[1],"your turn");
  2553. strcpy(txt_infoP2[0],"randul tau"); strcpy(txt_infoP2[1],"your turn");
  2554. strcpy(txt_infoMutari[0],"mutari ramase: "); strcpy(txt_infoMutari[1],"turns left: ");
  2555. strcpy(txt_infoTimer,"00:");
  2556.  
  2557. // informatii text
  2558. fundal == WHITE ? setcolor(BLACK):setcolor(WHITE);
  2559. setbkcolor(fundal);
  2560. settextjustify(CENTER_TEXT, CENTER_TEXT);
  2561.  
  2562. settextstyle(3,0,4);
  2563. readimagefile(imgPiesaA[aspect_j1], COORD1(pozPiesaA)); // tabela
  2564. outtextxy(COORD2(pozScor), "0 - 0"); // de
  2565. readimagefile(imgPiesaB[aspect_j2], COORD1(pozPiesaB)); // scor
  2566.  
  2567. char txtNrMutari[12]; itoa(nr_mutari, txtNrMutari);
  2568. char txtInfoMutari[LEN]; strcpy(txtInfoMutari, txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  2569. settextstyle(8,0,3);
  2570. outtextxy(COORD2(pozRamase), txtInfoMutari);
  2571.  
  2572. char txtTimp[12]; itoa(nr_timp, txtTimp);
  2573. if(nr_timp < 10) txtTimp[1] = txtTimp[0], txtTimp[0] = '0', txtTimp[2] = NULL;
  2574. char txtInfoTimer[LEN]; strcpy(txtInfoTimer, txt_infoTimer); strcat(txtInfoTimer,txtTimp);
  2575. settextstyle(3,0,8);
  2576. outtextxy(COORD2(pozTimer), txtInfoTimer); // timer
  2577.  
  2578. // istoric mutari
  2579. readimagefile(imgIstoric[mod], COORD1(pozIstoric));
  2580. pozMutare[0] = pozIstoric[limba][0]+12;
  2581. pozMutare[1] = pozIstoric[limba][1]+12;
  2582.  
  2583. // buton abandon
  2584. readimagefile(imgAbandon[mod][limba], COORD1(pozAbandon));
  2585.  
  2586. // joc
  2587. initializareTabla();
  2588.  
  2589. sizeAI = 0; // nr piese ai
  2590. scor_j1 = scor_j2 = 0;
  2591. mutari_ramase = nr_mutari;
  2592. timp_limita = nr_timp;
  2593. timp_expirat = joc_terminat = false;
  2594.  
  2595. strcpy(txt_logs[0], "NULL");
  2596.  
  2597. settextstyle(8,0,2);
  2598. outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  2599.  
  2600. while(joc_terminat == false)
  2601. {
  2602. timp_limita = nr_timp;
  2603. mutarePiesa(0,1);
  2604. joc_terminat = verificaSfarsit();
  2605. if(joc_terminat == false)
  2606. {
  2607. timp_limita = nr_timp;
  2608. mutarePiesa(1,0);
  2609. joc_terminat = verificaSfarsit();
  2610. }
  2611. }
  2612.  
  2613. scor_j1 == scor_j2 ? Sfarsit(2,1) : Sfarsit(1,1);
  2614. return;
  2615. }
  2616.  
  2617. void Reluare()
  2618. {
  2619. // curata ecran
  2620. setfillstyle(SOLID_FILL, fundal);
  2621. bar(0,0,LUNGIME,LATIME);
  2622.  
  2623. // butoane muzica
  2624. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2625. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2626.  
  2627. // buton inapoi
  2628. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2629.  
  2630. // resetare text
  2631. strcpy(txt_infoP1[0],"randul tau"); strcpy(txt_infoP1[1],"your turn");
  2632. strcpy(txt_infoP2[0],"randul tau"); strcpy(txt_infoP2[1],"your turn");
  2633. strcpy(txt_infoMutari[0],"mutari ramase: "); strcpy(txt_infoMutari[1],"turns left: ");
  2634. strcpy(txt_infoTimer,"00:");
  2635.  
  2636. // informatii text
  2637. fundal == WHITE ? setcolor(BLACK):setcolor(WHITE);
  2638. setbkcolor(fundal);
  2639. settextjustify(CENTER_TEXT, CENTER_TEXT);
  2640.  
  2641. // tabela de scor
  2642. settextstyle(3,0,4);
  2643. readimagefile(imgPiesaA[aspect_j1], COORD1(pozPiesaA));
  2644. outtextxy(COORD2(pozScor), "0 - 0");
  2645. readimagefile(imgPiesaB[aspect_j2], COORD1(pozPiesaB));
  2646.  
  2647. // citeste fisierul de replay
  2648. ifstream in("replay.info");
  2649.  
  2650. char c; in>>c; in.ignore();
  2651. int razboi_in4 = (c == '0' ? 1:2);
  2652. cout<<razboi_in4;
  2653.  
  2654. mutari_ramase = 0;
  2655.  
  2656. char txt_replay[102][LEN];
  2657. while(!in.eof()) // cate mutari s-au jucat ?
  2658. {
  2659. in.get(txt_replay[mutari_ramase++],LEN);
  2660. in.ignore();
  2661. }
  2662. mutari_ramase--; // fara mesajul de la final
  2663.  
  2664. // afiseaza <nr mutari ramase>
  2665. char txtNrMutari[12]; itoa(mutari_ramase, txtNrMutari);
  2666. char txtInfoMutari[LEN]; strcpy(txtInfoMutari, txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  2667. settextstyle(8,0,3);
  2668. outtextxy(COORD2(pozRamase), txtInfoMutari);
  2669.  
  2670. // afiseaza ghid utilizare mouse
  2671. char imgMouse[2][2][LEN] = {"img/mouseDRO.jpg","img/mouseDEN.jpg","img/mouseNRO.jpg","img/mouseNEN.jpg"};
  2672. readimagefile(imgMouse[mod][limba], 1320, 696, 1512, 888);
  2673.  
  2674. // joc
  2675. int scor1 = 0, scor2 = 0;
  2676. initializareTabla(razboi_in4);
  2677.  
  2678. settextstyle(8,0,2);
  2679. outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  2680.  
  2681.  
  2682. int index_mutare = 0;
  2683. bool hover_inapoi = false;
  2684.  
  2685. while(true)
  2686. {
  2687. clearmouseclick(WM_MOUSEMOVE);
  2688. clearmouseclick(WM_LBUTTONDOWN);
  2689. clearmouseclick(WM_LBUTTONDBLCLK);
  2690. clearmouseclick(WM_RBUTTONDOWN);
  2691. clearmouseclick(WM_RBUTTONDBLCLK);
  2692.  
  2693. int x = mousex();
  2694. int y = mousey();
  2695.  
  2696. // hover buton inapoi
  2697. if(esteDeasupra(x,y,pozInapoi))
  2698. {
  2699. if(mod_sfx == PORNIT && hover_inapoi == false) sunetHover.play();
  2700. hover_inapoi = true;
  2701. readimagefile(imgInapoi[(mod+1)%2], COORD1(pozInapoi));
  2702. }
  2703. else
  2704. {
  2705. hover_inapoi = false;
  2706. readimagefile(imgInapoi[mod], COORD1(pozInapoi));
  2707. }
  2708.  
  2709. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2710. {
  2711. clearmouseclick(WM_LBUTTONDOWN);
  2712. clearmouseclick(WM_LBUTTONDBLCLK);
  2713.  
  2714. // buton muzica
  2715. if(esteDeasupra(x,y,pozMuzica))
  2716. {
  2717. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  2718. {
  2719. muzicaFundal.stop();
  2720. mod_muzica = OPRIT;
  2721. }
  2722. else
  2723. {
  2724. muzicaFundal.play();
  2725. mod_muzica = PORNIT;
  2726. }
  2727.  
  2728. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2729. }
  2730. // buton sfx
  2731. else if(esteDeasupra(x,y,pozSfx))
  2732. {
  2733. mod_sfx = (mod_sfx+1) % 2;
  2734. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  2735. }
  2736. // buton inapoi
  2737. else if(esteDeasupra(x,y,pozInapoi))
  2738. {
  2739. if(mod_sfx == PORNIT) sunetInainte.play();
  2740. JocNou();
  2741. return;
  2742. }
  2743. else // vizualizeaza mutarea urmatoare
  2744. {
  2745. if(index_mutare < mutari_ramase)
  2746. {
  2747. char mutare[LEN]; strcpy(mutare,txt_replay[index_mutare]);
  2748.  
  2749. for(int i = 3; i < strlen(mutare); i++)
  2750. {
  2751. if(mutare[i] == 'x') break; // jucatorul nu a mutat in aceasta tura
  2752.  
  2753. if(mutare[i] == '(') // sterge o piesa; "(-cl)" c = coloana, l = linie
  2754. {
  2755. int coloana = (mutare[i+2]-'a');
  2756. int linie = 8-(mutare[i+3]-'0');
  2757.  
  2758. tabla[linie][coloana] == JUCATOR1 ? ++scor2 : ++scor1;
  2759.  
  2760. tabla[linie][coloana] *= (-1);
  2761. stergePiesa(linie,coloana);
  2762. i+=4;
  2763. }
  2764. else if(mutare[i] != ' ') // muta o piesa; "c1l1-c2l2"
  2765. {
  2766. int coloana1 = (mutare[i]-'a');
  2767. int linie1 = 8-(mutare[i+1]-'0');
  2768. int coloana2 = (mutare[i+3]-'a');
  2769. int linie2 = 8-(mutare[i+4]-'0');
  2770.  
  2771. tabla[linie2][coloana2] = (index_mutare%2)+1;
  2772. stergePiesa(linie1,coloana1);
  2773. deseneazaPiesa(linie2,coloana2,(index_mutare%2)+1);
  2774. i+=4;
  2775. }
  2776. }
  2777.  
  2778. index_mutare++;
  2779.  
  2780. // actualizare mutari ramase si text nr mutari
  2781. char txtNrMutari[12]; itoa(mutari_ramase-index_mutare, txtNrMutari);
  2782. char txtInfoMutari[LEN]; strcpy(txtInfoMutari,txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  2783. settextstyle(8,0,3);
  2784. bar(pozRamase[0]-200,pozRamase[1]-100,pozRamase[0]+150,pozRamase[1]+100);
  2785. outtextxy(COORD2(pozRamase), txtInfoMutari);
  2786.  
  2787. // actualizare text scor
  2788. settextstyle(3,0,4);
  2789. char txtScor1[12], txtScor2[12]; itoa(scor1,txtScor1); itoa(scor2,txtScor2);
  2790. char txtScor[LEN] = ""; strcat(txtScor,txtScor1); strcat(txtScor," - "); strcat(txtScor,txtScor2);
  2791. outtextxy(COORD2(pozScor), txtScor);
  2792.  
  2793. // actualizare text tura jucator
  2794. settextstyle(8,0,3);
  2795. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2796. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2797.  
  2798. if((index_mutare%2)+1 == JUCATOR1) outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  2799. else outtextxy(COORD2(pozRand2), txt_infoP2[limba]);
  2800.  
  2801. if(index_mutare == mutari_ramase)
  2802. {
  2803. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2804. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2805.  
  2806. char txtRezultat[LEN]; strcpy(txtRezultat, txt_replay[mutari_ramase]);
  2807. for(int i = 0; i < strlen(txtRezultat); i++)
  2808. if(strchr(":\n\0", txtRezultat[i]))
  2809. {
  2810. txtRezultat[i] = NULL;
  2811. break;
  2812. }
  2813.  
  2814. if(strcmp(txtRezultat,"egalitate") == 0 || strcmp(txtRezultat,"draw") == 0)
  2815. {
  2816. (limba == RO) ? strcpy(txtRezultat,"egalitate") : strcpy(txtRezultat,"draw");
  2817. outtextxy(COORD2(pozRand1), txtRezultat);
  2818. outtextxy(COORD2(pozRand2), txtRezultat);
  2819. }
  2820. else (mutari_ramase%2)+1 == JUCATOR1 ? outtextxy(COORD2(pozRand2), txtRezultat) : outtextxy(COORD2(pozRand1), txtRezultat);
  2821. }
  2822. }
  2823. }
  2824. }
  2825. else if((ismouseclick(WM_RBUTTONDOWN) || ismouseclick(WM_RBUTTONDBLCLK)) && index_mutare > 0) // da in spate cu o mutare
  2826. {
  2827. index_mutare--;
  2828.  
  2829. char mutare[LEN]; strcpy(mutare,txt_replay[index_mutare]);
  2830.  
  2831. for(int i = 3; i < strlen(mutare); i++)
  2832. {
  2833. if(mutare[i] == 'x') break; // jucatorul nu a mutat in aceasta tura
  2834.  
  2835. if(mutare[i] == '(') // pun la loc piesa stearsa, refac scorurile
  2836. {
  2837. int coloana = (mutare[i+2]-'a');
  2838. int linie = 8-(mutare[i+3]-'0');
  2839.  
  2840. tabla[linie][coloana] *= (-1);
  2841. tabla[linie][coloana] == JUCATOR1 ? --scor2 : --scor1;
  2842.  
  2843. deseneazaPiesa(linie,coloana,tabla[linie][coloana]);
  2844. i+=4;
  2845. }
  2846. else if(mutare[i] != ' ') // anulez mutarea, pun piesa unde era inainte
  2847. {
  2848. int coloana1 = (mutare[i]-'a');
  2849. int linie1 = 8-(mutare[i+1]-'0');
  2850. int coloana2 = (mutare[i+3]-'a');
  2851. int linie2 = 8-(mutare[i+4]-'0');
  2852.  
  2853. tabla[linie1][coloana1] = (index_mutare%2)+1;
  2854. stergePiesa(linie2,coloana2);
  2855. deseneazaPiesa(linie1,coloana1,(index_mutare%2)+1);
  2856. i+=4;
  2857. }
  2858. }
  2859.  
  2860. // actualizare mutari ramase si text nr mutari
  2861. char txtNrMutari[12]; itoa(mutari_ramase-index_mutare, txtNrMutari);
  2862. char txtInfoMutari[LEN]; strcpy(txtInfoMutari,txt_infoMutari[limba]); strcat(txtInfoMutari,txtNrMutari);
  2863. settextstyle(8,0,3);
  2864. bar(pozRamase[0]-200,pozRamase[1]-100,pozRamase[0]+150,pozRamase[1]+100);
  2865. outtextxy(COORD2(pozRamase), txtInfoMutari);
  2866.  
  2867. // actualizare text tura jucator
  2868. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2869. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2870.  
  2871. if((index_mutare%2)+1 == JUCATOR1) outtextxy(COORD2(pozRand1), txt_infoP1[limba]);
  2872. else outtextxy(COORD2(pozRand2), txt_infoP2[limba]);
  2873.  
  2874. // actualizare text scor
  2875. settextstyle(3,0,4);
  2876. char txtScor1[12], txtScor2[12]; itoa(scor1,txtScor1); itoa(scor2,txtScor2);
  2877. char txtScor[LEN] = ""; strcat(txtScor,txtScor1); strcat(txtScor," - "); strcat(txtScor,txtScor2);
  2878. outtextxy(COORD2(pozScor), txtScor);
  2879. }
  2880. }
  2881. }
  2882.  
  2883. void Sfarsit(int cod, int altcod) // 0 = capitulare, 1 = victorie meci complet, 2 = egalitate meci complet
  2884. {
  2885. settextstyle(8,0,3);
  2886. settextjustify(CENTER_TEXT,CENTER_TEXT);
  2887.  
  2888. if(cod == 0) // un jucator a capitulat
  2889. {
  2890. if(mod_sfx == PORNIT) sunetVictorie.play();
  2891.  
  2892. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2893. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2894.  
  2895. if(turaJucator() == JUCATOR2)
  2896. {
  2897. limba == RO ? outtextxy(COORD2(pozRand1), "castigator") : outtextxy(COORD2(pozRand1), "winner");
  2898. castigator = JUCATOR1;
  2899. }
  2900. else
  2901. {
  2902. limba == RO ? outtextxy(COORD2(pozRand2), "castigator") : outtextxy(COORD2(pozRand2), "winner");
  2903. castigator = JUCATOR2;
  2904. }
  2905.  
  2906. readimagefile(imgVictorie[mod][limba], COORD1(pozRezultat));
  2907.  
  2908. }
  2909. else if(cod == 1) // un jucator a castigat meciul
  2910. {
  2911. if(mod_sfx == PORNIT) sunetVictorie.play();
  2912.  
  2913. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2914. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2915.  
  2916. if(scor_j1 > scor_j2)
  2917. {
  2918. limba == RO ? outtextxy(COORD2(pozRand1), "castigator") : outtextxy(COORD2(pozRand1), "winner");
  2919. castigator = JUCATOR1;
  2920. }
  2921. else
  2922. {
  2923. limba == RO ? outtextxy(COORD2(pozRand2), "castigator") : outtextxy(COORD2(pozRand2), "winner");
  2924. castigator = JUCATOR2;
  2925. }
  2926.  
  2927. readimagefile(imgVictorie[mod][limba], COORD1(pozRezultat));
  2928. }
  2929. else // egalitate
  2930. {
  2931. if(mod_sfx == PORNIT) sunetEgal.play();
  2932.  
  2933. bar(pozRand1[0]-80,pozRand1[1]-15,pozRand1[0]+80,pozRand1[1]+15);
  2934. bar(pozRand2[0]-80,pozRand2[1]-15,pozRand2[0]+80,pozRand2[1]+15);
  2935.  
  2936. castigator = 0;
  2937. readimagefile(imgEgal[mod][limba], COORD1(pozRezultat));
  2938.  
  2939. }
  2940.  
  2941. readimagefile(imgSfarsit[mod], COORD1(pozSfarsit));
  2942.  
  2943. readimagefile(imgRestart[mod], COORD1(pozRestart));
  2944. readimagefile(imgSalveaza[mod][limba], COORD1(pozSalveaza));
  2945. readimagefile(imgLaMeniu[mod][limba], COORD1(pozLaMeniu));
  2946.  
  2947. bool joc_salvat = false;
  2948.  
  2949. while(true)
  2950. {
  2951. clearmouseclick(WM_LBUTTONDOWN);
  2952. clearmouseclick(WM_MOUSEMOVE);
  2953.  
  2954. int x = mousex();
  2955. int y = mousey();
  2956.  
  2957. // buton muzica
  2958. if(esteDeasupra(x,y,pozMuzica))
  2959. {
  2960. while(true)
  2961. {
  2962. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2963. {
  2964. clearmouseclick(WM_LBUTTONDOWN);
  2965. clearmouseclick(WM_LBUTTONDBLCLK);
  2966. if(mod_muzica == PORNIT) // muzica este pornita, deci o oprim
  2967. {
  2968. muzicaFundal.stop();
  2969. mod_muzica = OPRIT;
  2970. }
  2971. else
  2972. {
  2973. muzicaFundal.play();
  2974. mod_muzica = PORNIT;
  2975. }
  2976.  
  2977. readimagefile(imgMuzica[mod][mod_muzica], COORD1(pozMuzica));
  2978. }
  2979. if(ismouseclick(WM_MOUSEMOVE))
  2980. {
  2981. clearmouseclick(WM_MOUSEMOVE);
  2982. x = mousex();
  2983. y = mousey();
  2984.  
  2985. if(!esteDeasupra(x,y,pozMuzica)) break;
  2986. }
  2987. }
  2988. }
  2989. // buton sfx
  2990. else if(esteDeasupra(x,y,pozSfx))
  2991. {
  2992. while(true)
  2993. {
  2994. if(ismouseclick(WM_LBUTTONDOWN) || ismouseclick(WM_LBUTTONDBLCLK))
  2995. {
  2996. clearmouseclick(WM_LBUTTONDOWN);
  2997. clearmouseclick(WM_LBUTTONDBLCLK);
  2998. mod_sfx = (mod_sfx+1) % 2;
  2999.  
  3000. readimagefile(imgSfx[mod][mod_sfx], COORD1(pozSfx));
  3001. }
  3002. if(ismouseclick(WM_MOUSEMOVE))
  3003. {
  3004. clearmouseclick(WM_MOUSEMOVE);
  3005. x = mousex();
  3006. y = mousey();
  3007.  
  3008. if(!esteDeasupra(x,y,pozSfx)) break;
  3009. }
  3010. }
  3011. }
  3012. // buton restart
  3013. else if(esteDeasupra(x,y,pozRestart))
  3014. {
  3015. if(mod_sfx == PORNIT) sunetHover.play();
  3016. readimagefile(imgRestart[(mod+1)%2], COORD1(pozRestart));
  3017.  
  3018. while(true)
  3019. {
  3020. if(ismouseclick(WM_LBUTTONDOWN))
  3021. {
  3022. clearmouseclick(WM_LBUTTONDOWN);
  3023. if(mod_sfx == PORNIT) sunetInainte.play();
  3024.  
  3025. Restart(altcod); // restart pvp? (0) sau ia? (1)
  3026. return;
  3027. }
  3028. if(ismouseclick(WM_MOUSEMOVE))
  3029. {
  3030. clearmouseclick(WM_MOUSEMOVE);
  3031. x = mousex();
  3032. y = mousey();
  3033.  
  3034. if(!esteDeasupra(x,y,pozRestart))
  3035. {
  3036. readimagefile(imgRestart[mod], COORD1(pozRestart));
  3037. break;
  3038. }
  3039. }
  3040. }
  3041. }
  3042. // buton salveaza meci
  3043. else if(joc_salvat == false && esteDeasupra(x,y,pozSalveaza))
  3044. {
  3045. if(mod_sfx == PORNIT) sunetHover.play();
  3046.  
  3047. readimagefile(imgSalveaza[(mod+1)%2][limba], COORD1(pozSalveaza));
  3048.  
  3049. while(true)
  3050. {
  3051. if(ismouseclick(WM_LBUTTONDOWN))
  3052. {
  3053. clearmouseclick(WM_LBUTTONDOWN);
  3054. if(mod_sfx == PORNIT) sunetInainte.play();
  3055.  
  3056. joc_salvat = true;
  3057. Salveaza();
  3058.  
  3059. readimagefile(imgSalvat[mod][limba], COORD1(pozSalveaza));
  3060. break;
  3061. }
  3062. if(ismouseclick(WM_MOUSEMOVE))
  3063. {
  3064. clearmouseclick(WM_MOUSEMOVE);
  3065. x = mousex();
  3066. y = mousey();
  3067.  
  3068. if(!esteDeasupra(x,y,pozSalveaza))
  3069. {
  3070. readimagefile(imgSalveaza[mod][limba], COORD1(pozSalveaza));
  3071. break;
  3072. }
  3073. }
  3074. }
  3075. }
  3076. // buton inapoi la meniu
  3077. else if(esteDeasupra(x,y,pozLaMeniu))
  3078. {
  3079. if(mod_sfx == PORNIT) sunetHover.play();
  3080.  
  3081. readimagefile(imgLaMeniu[(mod+1)%2][limba], COORD1(pozLaMeniu));
  3082.  
  3083. while(true)
  3084. {
  3085. if(ismouseclick(WM_LBUTTONDOWN))
  3086. {
  3087. clearmouseclick(WM_LBUTTONDOWN);
  3088. if(mod_sfx == PORNIT) sunetInainte.play();
  3089.  
  3090. if(mod_muzica == PORNIT)
  3091. {
  3092. muzicaFundal.openFromFile("audio/bgm.wav");
  3093. muzicaFundal.setLoop(true); muzicaFundal.setVolume(50.f); muzicaFundal.play();
  3094. }
  3095. Meniu();
  3096. return;
  3097. }
  3098. if(ismouseclick(WM_MOUSEMOVE))
  3099. {
  3100. clearmouseclick(WM_MOUSEMOVE);
  3101. x = mousex();
  3102. y = mousey();
  3103.  
  3104. if(!esteDeasupra(x,y,pozLaMeniu))
  3105. {
  3106. readimagefile(imgLaMeniu[mod][limba], COORD1(pozLaMeniu));
  3107. break;
  3108. }
  3109. }
  3110. }
  3111. }
  3112. }
  3113. }
  3114.  
  3115. void Restart(int cod) // 0 = pvp, 1 = pvia
  3116. {
  3117. initializareTabla(cod);
  3118. if(cod == 0) PVP();
  3119. else PVIA();
  3120. }
  3121.  
  3122. void Salveaza()
  3123. {
  3124. ofstream out("replay.info");
  3125. out << (nr_safe != 0) << '\n'; // razboi in 8 sau in 4?
  3126.  
  3127. int ind = 0;
  3128. while(strcmp(txt_logs[ind],"NULL")) out << txt_logs[ind++] << '\n';
  3129.  
  3130. if(castigator == 0) out << (limba == RO ? "egalitate":"draw");
  3131. else
  3132. {
  3133. if(castigator == 1) out << (limba == RO ? "castigator: jucator1":"winner: player1");
  3134. else out << (limba == RO ? "castigator: jucator2":"winner: player2");
  3135. }
  3136.  
  3137. out.close();
  3138. }
  3139.  
  3140. int main()
  3141. {
  3142. initwindow(LUNGIME,LATIME, "Razboi în Opt | War in Eight");
  3143.  
  3144. Initializari();
  3145. Meniu();
  3146.  
  3147. getch();
  3148. closegraph();
  3149. return 0;
  3150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement