Advertisement
svab0ni

Untitled

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