Вы находитесь на странице: 1из 5

#include<stdio.

h>
#include<conio.h>
#include<graphics.h>
#include<stdlib.h>
#include<dos.h>
#include<process.h>
#include<iostream.h>
float l=2,w=0,t=0,p,k=3;
void select(int l);
void cd(int x,int y);
void fall(int,int,int,int,int,int,int);
void perform(int,int);
void text();
int check(int a);
void main()
{
int i,gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(0);
fall(40,110,180,250,320,390,460);
getch();
}
void cd(int x,int y)
{
circle(x,y,30);
setcolor(WHITE);
line(0,380,650,380);
line(0,30,650,30);
line(400,0,400,30);
line(410,0,410,30);
}
void fall(int x, int x1, int x2,int x3,int x4, int x5,int x6) //if u have n circ
le pass n parameters
{
int y1,y2,y3,y4,y5,y6,y7,i=1,a=0,key; //y1 for 1st circle so yn for nth circle h
eight;
y1=y2=y3=y4=y5=y6=y7=70;
while(1) //how many times u want ur circle 2 fall, u can use kbhit instead
{
setcolor(WHITE);
text();
a=a+1;
a=check(a);
setcolor(a);
cd(x,y1);
setfillstyle(SOLID_FILL,a);
floodfill(x,y1,a);
a=a+1;
a=check(a);
setcolor(a);
cd(x1,y2);
setfillstyle(SOLID_FILL,a);
floodfill(x1,y2,a);
a=a+1;
setcolor(a);
cd(x2,y3);
setfillstyle(SOLID_FILL,a);
floodfill(x2,y3,a);
a=a+1;
setcolor(a);
cd(x3,y4);
setfillstyle(SOLID_FILL,a);
floodfill(x3,y4,a);
a=a+1;
a=check(a);
setcolor(a);
cd(x4,y5);
setfillstyle(SOLID_FILL,a);
floodfill(x4,y5,a);
a=a+1;
a=check(a);
setcolor(a);
cd(x5,y6);
setfillstyle(SOLID_FILL,a);
floodfill(x5,y6,a);
a=a+1;
a=check(a);
setcolor(a);
cd(x6,y7);
setfillstyle(SOLID_FILL,a);
floodfill(x6,y7,a);
if(l>9)
l=1;
select(l);
if(kbhit())
{
key=getch();
if(key==49)
perform(x,y1);
if(key==50)
perform(x1,y2);
if(key==51)
perform(x2,y3);
if(key==52)
perform(x3,y4);
if(key==53)
perform(x4,y5);
if(key==54)
perform(x5,y6);
if(key==55)
perform(x6,y7);
if(key==48)
{
cleardevice();
p=w/t;
p=p*100;
cout<<"\n\n\t\tCorrect-> "<<w<<" out of "<<t;
printf("\n\t\tAccuracy Percentage= %f ",p);
getch();
exit(0);
}
}
if(k<=0&&k>-3)
sleep(1);
else if(k<=-3)
delay(400+k);
else
sleep(k);
cleardevice();
i++;
y1=y1+10; //falling with different speed
y2=y2+5;
y3=y3+15;
y4=y4+20;
y5=y5+8;
y6=y6+13;
y7=y7+18;
if(y1>330)
y1=70;
if(y2>330)
y2=70;
if(y3>330)
y3=70;
if(y4>330)
y4=70;
if(y5>330)
y5=70;
if(y6>330)
y6=70;
if(y7>330)
y7=70;
}
}
void perform(int x, int y)
{
int color;
color=getpixel(x,y);
color=color+2;
if(color>9)
color=color-9;
cleardevice();
switch (color)
{
case 1:
setcolor(1);
circle(100,100,100);
outtextxy(80,100,"Color Code=1");
break;
case 2:
setcolor(2);
circle(100,100,100);
outtextxy(80,100,"Color Code=2");
break;
case 3:
setcolor(3);
circle(100,100,100);
outtextxy(80,100,"Color Code=3");
break;
case 4:
setcolor(4);
circle(100,100,100);
outtextxy(80,100,"Color Code=4");
break;
case 5:
setcolor(5);
circle(100,100,100);
outtextxy(80,100,"Color Code=5");
break;
case 6:
setcolor(6);
circle(100,100,100);
outtextxy(80,100,"Color Code=6");
break;
case 7:
setcolor(7);
circle(100,100,100);
outtextxy(80,100,"Color Code=7");
break;
case 8:
setcolor(8);
circle(100,100,100);
outtextxy(80,100,"Color Code=8");
break;
case 9:
setcolor(9);
circle(100,100,100);
outtextxy(80,100,"Color Code=9");
break;
default:
setcolor(10);
circle(100,100,100);
outtextxy(80,100,"Color Code>9");
break;
}
if(color==l)
{
outtextxy(350,100,"Right Color");
w=w+1;
t=t+1;
k=k-1;
}
else
{
outtextxy(350,100,"Wrong Color");
t=t+1;
}
sleep(1);
l=l+1;
cleardevice();
}
void text()
{
outtextxy(40,400,"1");
outtextxy(110,400,"2");
outtextxy(180,400,"3");
outtextxy(250,400,"4");
outtextxy(320,400,"5");
outtextxy(390,400,"6");
outtextxy(460,400,"7");
outtextxy(100,450,"Press 1 for 1st circle and so on!!");
outtextxy(100,460,"Press 0 to EXIT");
outtextxy(10,10,"Check your ACCURACY!!!!");
}
void select(int l)
{
setcolor(1);
if(l== 1)
outtextxy(420,10,"Select BLUE Color Code=1");
setcolor(2);
if(l== 2)
outtextxy(420,10,"Select GREEN Color Code=2");
setcolor(3);
if(l== 3)
outtextxy(420,10,"Select CYAN Color Code=3");
setcolor(4);
if(l==4)
outtextxy(420,10,"Select RED Color Code=4");
setcolor(5);
if(l== 5)
outtextxy(420,10,"Select MAGENTA Color Code=5");
setcolor(6);
if(l== 6)
outtextxy(420,10,"Select BROWN Color Code=6");
setcolor(7);
if(l== 7)
outtextxy(420,10,"Select LIGHT GRAY Color Code=7");
setcolor(8);
if(l== 8)
outtextxy(420,10,"Select DARK GRAY Color Code=8");
setcolor(9);
if(l== 9)
outtextxy(420,10,"Select LIGHT BLUE Color Code=9");
setcolor(WHITE);
}
int check(int a)
{
if(a>9)
return 1;
else
return a;
}

Вам также может понравиться