Advertisement
svab0ni

Untitled

Dec 17th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.66 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.             {
  94.             cleardevice();
  95.             first = true;
  96.             //1
  97.             setfillstyle(SOLID_FILL, RED);
  98.             setcolor(RED);
  99.             srand (time(NULL));
  100.             int randomX = 50 + (rand() % 490);
  101.             int randomY = 50 + (rand() % 370);
  102.             circle(randomX,randomY,50);
  103.             floodfill(randomX,randomY,RED);
  104.             coordinates[0][0] = randomX;
  105.             coordinates[0][1] = randomY;
  106.             //2
  107.             randomX = 50 + (rand() % 490);
  108.             randomY = 50 + (rand() % 370);
  109.             circle(randomX,randomY,50);
  110.             floodfill(randomX,randomY,RED);
  111.             coordinates[1][0] = randomX;
  112.             coordinates[1][1] = randomY;
  113.             //3
  114.             randomX = 50 + (rand() % 490);
  115.             randomY = 50 + (rand() % 370);
  116.             circle(randomX,randomY,50);
  117.             floodfill(randomX,randomY,RED);
  118.             coordinates[2][0] = randomX;
  119.             coordinates[2][1] = randomY;
  120.  
  121.         }
  122.  
  123.         if(ismouseclick(WM_MOUSEMOVE))
  124.         {
  125.             cleardevice();
  126.             for(int i=0; i<3;i++)
  127.             {
  128.                 if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
  129.                 {
  130.                     setfillstyle(SOLID_FILL, RED);
  131.                     setcolor(RED);
  132.                     circle(coordinates[i][0],coordinates[i][1],50);
  133.                     floodfill(coordinates[i][0],coordinates[i][1],RED);
  134.                 }
  135.  
  136.             }
  137.             line(mousex()-20, mousey(), mousex()+20, mousey());
  138.             line(mousex(), mousey()-20, mousex(), mousey()+20);
  139.         }
  140.         clearmouseclick(WM_MOUSEMOVE);
  141.  
  142.         if(ismouseclick(WM_LBUTTONDOWN))
  143.         {
  144.             for(int i=0; i<3;i++)
  145.             {
  146.                 if((mousex()>coordinates[i][0])&&(mousex()<coordinates[i][0])&&(mousey()>coordinates[i][1])&&(mousey()<coordinates[i][1]))
  147.                 {
  148.                     coordinates[i][0] = -1;
  149.                     coordinates[i][1] = -1;
  150.                     bro=bro+1;
  151.                     PlaySound(TEXT("Skorpion.wav"),NULL, SND_FILENAME);
  152.                    
  153.                     counter++;
  154.                 }
  155.             }
  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.  
  169.         }
  170.         clearmouseclick(WM_LBUTTONDOWN);
  171.         if(counter == 2) break;
  172.     }
  173.  
  174.     while(dif!=kbhit())
  175.     {
  176.         if(bro==1)break;
  177.         if(ismouseclick(WM_MOUSEMOVE))
  178.         {
  179.             cleardevice();
  180.             line(mousex()-20, mousey(), mousex()+20, mousey());
  181.             line(mousex(), mousey()-20, mousex(), mousey()+20);
  182.         }
  183.         clearmouseclick(WM_MOUSEMOVE);
  184.     }
  185.  
  186.  
  187.     settextstyle(GOTHIC_FONT,HORIZ_DIR,8);
  188.     outtextxy(55,100,"THE END");
  189. }
  190.  
  191. /*Hard mode*/
  192. /*.....*/
  193.  
  194.     /*Footer*/
  195.     getch();
  196.     closegraph();
  197.     return 0;
  198.  
  199. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement