Advertisement
svab0ni

Untitled

Dec 17th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.71 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.                     circle(coordinates[i][0],coordinates[i][1],50);
  131.                     floodfill(coordinates[i][0],coordinates[i][1],RED);
  132.                 }
  133.  
  134.             }
  135.             line(mousex()-20, mousey(), mousex()+20, mousey());
  136.             line(mousex(), mousey()-20, mousex(), mousey()+20);
  137.         }
  138.         clearmouseclick(WM_MOUSEMOVE);
  139.         cleardevice();
  140.         for(int i=0; i<3;i++)
  141.             {
  142.                 if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
  143.                 {
  144.                     circle(coordinates[i][0],coordinates[i][1],50);
  145.                     floodfill(coordinates[i][0],coordinates[i][1],RED);
  146.                 }
  147.             }
  148.         if(ismouseclick(WM_LBUTTONDOWN))
  149.         {
  150.             cleardevice();
  151.             for(int i=0; i<3;i++)
  152.             {
  153.                 if((mousex()>coordinates[i][0])&&(mousex()<coordinates[i][0])&&(mousey()>coordinates[i][1])&&(mousey()<coordinates[i][1]))
  154.                 {
  155.                     coordinates[i][0] = -1;
  156.                     coordinates[i][1] = -1;
  157.                     bro=bro+1;
  158.                     PlaySound(TEXT("Skorpion.wav"),NULL, SND_FILENAME);
  159.                     counter++;
  160.                 }
  161.             }
  162.             for(int i=0; i<3;i++)
  163.             {
  164.                 if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
  165.                 {
  166.                     circle(coordinates[i][0],coordinates[i][1],50);
  167.                     floodfill(coordinates[i][0],coordinates[i][1],RED);
  168.                 }
  169.             }
  170.         }
  171.         clearmouseclick(WM_LBUTTONDOWN);
  172.         if(counter == 2) break;
  173.     }
  174.  
  175.     while(dif!=kbhit())
  176.     {
  177.         if(bro==1)break;
  178.         if(ismouseclick(WM_MOUSEMOVE))
  179.         {
  180.             cleardevice();
  181.             line(mousex()-20, mousey(), mousex()+20, mousey());
  182.             line(mousex(), mousey()-20, mousex(), mousey()+20);
  183.         }
  184.         clearmouseclick(WM_MOUSEMOVE);
  185.     }
  186.  
  187.  
  188.     settextstyle(GOTHIC_FONT,HORIZ_DIR,8);
  189.     outtextxy(55,100,"THE END");
  190. }
  191.  
  192. /*Hard mode*/
  193. /*.....*/
  194.  
  195.     /*Footer*/
  196.     getch();
  197.     closegraph();
  198.     return 0;
  199.  
  200. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement