Advertisement
svab0ni

Untitled

Dec 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.65 KB | None | 0 0
  1. /*Header*/
  2.  
  3. #include <iostream>
  4. #include <winbgim.h>
  5. #include <cstdlib>
  6. #include <windows.h>
  7. #include <MMSystem.h>
  8. #include <string>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <time.h>
  12. using namespace std;
  13. int main()
  14. {
  15. int gdriver=9; int gmode=2;
  16. initgraph(&gdriver, &gmode, "");
  17. setbkcolor(BLACK);
  18. setcolor(WHITE);
  19. cleardevice();
  20.  
  21. /*Menu screen*/
  22. int bro=0;
  23. int rad;
  24. settextstyle(SMALL_FONT,HORIZ_DIR,6);
  25. outtextxy(10,10, "Press ESC to exit");
  26. settextstyle(GOTHIC_FONT,HORIZ_DIR,10); setcolor(RED);
  27. outtextxy(55,100,"3USA"); setcolor(WHITE);
  28. settextstyle(SMALL_FONT,HORIZ_DIR,6);
  29. outtextxy(260,230,"Press ENTER to start");
  30.  
  31. rad=getch();
  32.  
  33. if(rad==27){getch(); closegraph(); return 0;}
  34. if(rad==13){
  35. cleardevice();
  36. outtextxy(260,230,"Choose difficulty");
  37. outtextxy(260,250,"EASY press E");
  38. outtextxy(260,270,"HARD press H");
  39.  
  40. char dif;
  41. dif=getch();
  42.  
  43. /*Easy mode*/
  44.  
  45. if(dif=='e'||dif=='E'){
  46. cleardevice();
  47.  
  48. for(int i=0;i<5;i++){
  49. if(i==1)
  50. {
  51. settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
  52. setcolor(RED);
  53. outtextxy(200,100,"3");
  54. delay(400);
  55. PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
  56. }
  57. if(i==2){
  58. cleardevice();
  59. settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
  60. setcolor(RED);
  61. outtextxy(200,100,"2");
  62. delay(400);
  63. PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
  64. }
  65. if(i==3)
  66. {
  67. cleardevice();
  68. settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
  69. setcolor(RED);
  70. outtextxy(200,100,"1");
  71. delay(400);
  72. PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
  73. }
  74. if(i==4)
  75. {
  76. cleardevice();
  77. settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
  78. setcolor(RED);
  79. outtextxy(150,100,"GO");
  80. delay(400);
  81. PlaySound(TEXT("beep-09"),NULL, SND_FILENAME);
  82. }
  83.  
  84. }
  85. int counter = 0;
  86. int coordinates[10][2];
  87. bool first = false;
  88.  
  89.  
  90. while(dif!=kbhit())
  91. {
  92. if(!first){
  93. first = true;
  94. //1
  95. setfillstyle(SOLID_FILL, RED);
  96. setcolor(RED);
  97. srand (time(NULL));
  98. int randomX = 50 + (rand() % 490);
  99. int randomY = 50 + (rand() % 370);
  100. circle(randomX,randomY,50);
  101. floodfill(randomX,randomY,RED);
  102. coordinates[0][0] = randomX;
  103. coordinates[0][1] = randomY;
  104. //2
  105. setfillstyle(SOLID_FILL, RED);
  106. setcolor(RED);
  107. srand (time(NULL));
  108. randomX = 50 + (rand() % 490);
  109. randomY = 50 + (rand() % 370);
  110. circle(randomX,randomY,50);
  111. floodfill(randomX,randomY,RED);
  112. coordinates[1][0] = randomX;
  113. coordinates[1][1] = randomY;
  114. //3
  115. setfillstyle(SOLID_FILL, RED);
  116. setcolor(RED);
  117. srand (time(NULL));
  118. randomX = 50 + (rand() % 490);
  119. randomY = 50 + (rand() % 370);
  120. circle(randomX,randomY,50);
  121. floodfill(randomX,randomY,RED);
  122. coordinates[2][0] = randomX;
  123. coordinates[2][1] = randomY;
  124.  
  125. }
  126.  
  127. if(ismouseclick(WM_MOUSEMOVE))
  128. {
  129. cleardevice();
  130. for(int i=0; i<3;i++)
  131. {
  132. if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
  133. {
  134. setfillstyle(SOLID_FILL, RED);
  135. setcolor(RED);
  136. circle(coordinates[i][0],coordinates[i][1],50);
  137. floodfill(coordinates[i][0],coordinates[i][1],RED);
  138. }
  139.  
  140. }
  141. line(mousex()-20, mousey(), mousex()+20, mousey());
  142. line(mousex(), mousey()-20, mousex(), mousey()+20);
  143. }
  144. clearmouseclick(WM_MOUSEMOVE);
  145.  
  146. if(ismouseclick(WM_LBUTTONDOWN))
  147. {
  148. for(int i=0; i<3;i++)
  149. {
  150. if((mousex()>coordinates[i][0])&&(mousex()<coordinates[i][0])&&(mousey()>coordinates[i][1])&&(mousey()<coordinates[i][1]))
  151. {
  152. coordinates[i][0] = -1;
  153. coordinates[i][1] = -1;
  154. bro=bro+1;
  155. PlaySound(TEXT("Skorpion.wav"),NULL, SND_FILENAME);
  156. cleardevice();
  157. for(int i=0; i<3;i++)
  158. {
  159. if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
  160. {
  161. setfillstyle(SOLID_FILL, RED);
  162. setcolor(RED);
  163. circle(coordinates[i][0],coordinates[i][1],50);
  164. floodfill(coordinates[i][0],coordinates[i][1],RED);
  165. }
  166.  
  167. }
  168. counter++;
  169. }
  170. }
  171.  
  172. }
  173. if(counter == 2) break;
  174. }
  175.  
  176. while(dif!=kbhit())
  177. {
  178. if(bro==1)break;
  179. if(ismouseclick(WM_MOUSEMOVE))
  180. {
  181. cleardevice();
  182. line(mousex()-20, mousey(), mousex()+20, mousey());
  183. line(mousex(), mousey()-20, mousex(), mousey()+20);
  184. }
  185. clearmouseclick(WM_MOUSEMOVE);
  186. }
  187.  
  188.  
  189. settextstyle(GOTHIC_FONT,HORIZ_DIR,8);
  190. outtextxy(55,100,"THE END");
  191. }
  192.  
  193. /*Hard mode*/
  194. /*.....*/
  195.  
  196. /*Footer*/
  197. getch();
  198. closegraph();
  199. return 0;
  200.  
  201. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement