Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Header*/
- #include <iostream>
- #include <winbgim.h>
- #include <cstdlib>
- #include <windows.h>
- #include <MMSystem.h>
- #include <string>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- int main()
- {
- int gdriver=9; int gmode=2;
- initgraph(&gdriver, &gmode, "");
- setbkcolor(BLACK);
- setcolor(WHITE);
- cleardevice();
- /*Menu screen*/
- int bro=0;
- int rad;
- settextstyle(SMALL_FONT,HORIZ_DIR,6);
- outtextxy(10,10, "Press ESC to exit");
- settextstyle(GOTHIC_FONT,HORIZ_DIR,10); setcolor(RED);
- outtextxy(55,100,"3USA"); setcolor(WHITE);
- settextstyle(SMALL_FONT,HORIZ_DIR,6);
- outtextxy(260,230,"Press ENTER to start");
- rad=getch();
- if(rad==27){getch(); closegraph(); return 0;}
- if(rad==13){
- cleardevice();
- outtextxy(260,230,"Choose difficulty");
- outtextxy(260,250,"EASY press E");
- outtextxy(260,270,"HARD press H");
- char dif;
- dif=getch();
- /*Easy mode*/
- if(dif=='e'||dif=='E'){
- cleardevice();
- for(int i=0;i<5;i++){
- if(i==1)
- {
- settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
- setcolor(RED);
- outtextxy(200,100,"3");
- delay(400);
- PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
- }
- if(i==2){
- cleardevice();
- settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
- setcolor(RED);
- outtextxy(200,100,"2");
- delay(400);
- PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
- }
- if(i==3)
- {
- cleardevice();
- settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
- setcolor(RED);
- outtextxy(200,100,"1");
- delay(400);
- PlaySound(TEXT("beep-07"),NULL, SND_FILENAME);
- }
- if(i==4)
- {
- cleardevice();
- settextstyle(GOTHIC_FONT,HORIZ_DIR,10);
- setcolor(RED);
- outtextxy(150,100,"GO");
- delay(400);
- PlaySound(TEXT("beep-09"),NULL, SND_FILENAME);
- }
- }
- int counter = 0;
- int coordinates[10][2];
- bool first = false;
- while(dif!=kbhit())
- {
- if(!first){
- first = true;
- //1
- setfillstyle(SOLID_FILL, RED);
- setcolor(RED);
- srand (time(NULL));
- int randomX = 50 + (rand() % 490);
- int randomY = 50 + (rand() % 370);
- circle(randomX,randomY,50);
- floodfill(randomX,randomY,RED);
- coordinates[0][0] = randomX;
- coordinates[0][1] = randomY;
- //2
- setfillstyle(SOLID_FILL, RED);
- setcolor(RED);
- srand (time(NULL));
- randomX = 50 + (rand() % 490);
- randomY = 50 + (rand() % 370);
- circle(randomX,randomY,50);
- floodfill(randomX,randomY,RED);
- coordinates[1][0] = randomX;
- coordinates[1][1] = randomY;
- //3
- setfillstyle(SOLID_FILL, RED);
- setcolor(RED);
- srand (time(NULL));
- randomX = 50 + (rand() % 490);
- randomY = 50 + (rand() % 370);
- circle(randomX,randomY,50);
- floodfill(randomX,randomY,RED);
- coordinates[2][0] = randomX;
- coordinates[2][1] = randomY;
- }
- if(ismouseclick(WM_MOUSEMOVE))
- {
- cleardevice();
- for(int i=0; i<3;i++)
- {
- if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
- {
- setfillstyle(SOLID_FILL, RED);
- setcolor(RED);
- circle(coordinates[i][0],coordinates[i][1],50);
- floodfill(coordinates[i][0],coordinates[i][1],RED);
- }
- }
- line(mousex()-20, mousey(), mousex()+20, mousey());
- line(mousex(), mousey()-20, mousex(), mousey()+20);
- }
- clearmouseclick(WM_MOUSEMOVE);
- if(ismouseclick(WM_LBUTTONDOWN))
- {
- for(int i=0; i<3;i++)
- {
- if((mousex()>coordinates[i][0])&&(mousex()<coordinates[i][0])&&(mousey()>coordinates[i][1])&&(mousey()<coordinates[i][1]))
- {
- coordinates[i][0] = -1;
- coordinates[i][1] = -1;
- bro=bro+1;
- PlaySound(TEXT("Skorpion.wav"),NULL, SND_FILENAME);
- cleardevice();
- for(int i=0; i<3;i++)
- {
- if(coordinates[i][0] != -1 && coordinates[i][1] != -1)
- {
- setfillstyle(SOLID_FILL, RED);
- setcolor(RED);
- circle(coordinates[i][0],coordinates[i][1],50);
- floodfill(coordinates[i][0],coordinates[i][1],RED);
- }
- }
- counter++;
- }
- }
- }
- if(counter == 2) break;
- }
- while(dif!=kbhit())
- {
- if(bro==1)break;
- if(ismouseclick(WM_MOUSEMOVE))
- {
- cleardevice();
- line(mousex()-20, mousey(), mousex()+20, mousey());
- line(mousex(), mousey()-20, mousex(), mousey()+20);
- }
- clearmouseclick(WM_MOUSEMOVE);
- }
- settextstyle(GOTHIC_FONT,HORIZ_DIR,8);
- outtextxy(55,100,"THE END");
- }
- /*Hard mode*/
- /*.....*/
- /*Footer*/
- getch();
- closegraph();
- return 0;
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement