C/C++ Graphics program to make an ILLUSION

































C/C++ Graphics program to make an ILLUSION


#include <graphics.h>
#include <conio.h>
#include <dos.h>
#define ENTER 13 //defining macro for enter key, 13 is the Enter key code

void dots(); //declaraing a function

void main()
{
int d,m;

d=DETECT;

initgraph(&d,&m,"c:\\tc\\bgi");

setcolor(1);
settextstyle(TRIPLEX_FONT,0,10);

outtextxy(30,1,"I");
setcolor(3);
outtextxy(50,50,"L");
setcolor(4);
outtextxy(85,90,"L");
setcolor(5);
outtextxy(125,140,"U");
setcolor(2);
outtextxy(185,180,"S");
setcolor(6);
outtextxy(240,220,"I");
setcolor(4);
outtextxy(265,260,"O");
setcolor(1);
outtextxy(305,310,"N");
setcolor(3);
outtextxy(395,320,"???") ;

setcolor(15);
setfillstyle(1,5);
fillellipse(400,200,50,50);

setfillstyle(1,15);
fillellipse(380,185,7,15);

setfillstyle(1,0);
fillellipse(380,191,5,10);

setfillstyle(1,15);
fillellipse(420,185,7,15);

setfillstyle(1,0);
fillellipse(420,191,5,10);

setfillstyle(1,4);
fillellipse(400,230,15,7);

setfillstyle(1,6);
fillellipse(400,205,7,7);


for(int x=340;x<400;x++)
{
setcolor(4);
outtextxy(x,42,"&");
}

setcolor(2);
settextstyle(SMALL_FONT,0,50);
outtextxy(500,100,"PRESS");
outtextxy(500,150,"ENTER!");

for(int s=200;s<300;s++)
{
for(int y=200;y<2000;y=y+s)
{
sound(y);
delay(150);
nosound();
}
break;
}

char k=getch();


if(k==ENTER)
{
sound(200);
delay(100);
sound(500);
delay(100);
nosound();

cleardevice();
setcolor(6);
settextstyle(7,0,8);
outtextxy(110,10,"GENIUS???");

setcolor(5);
outtextxy(60,125,"*****************");

setcolor(10);
settextstyle(7,0,4);
outtextxy(35,250,"COUNT THE NO. OF BLACK DOTS.....");

setcolor(14);
outtextxy(10,350,"PRESS ENTER TO SEE THE MAGIC!!!");

k=getch();
}

if(k==ENTER)
{
cleardevice();
dots();
}
getch();
closegraph();
}

void dots()
{
int i;

setcolor(8);
setfillstyle(1,8);

for(i=40;i < getmaxx();i=i+40)
{
bar(i,0,i+5,getmaxy());
}

for(i=40; i < getmaxx();i=i+40)
{
for(int j=40;j < getmaxy();j=j+40)
{
setcolor(15);
setfillstyle(1,15);
circle(i+2,j+2,5);
floodfill(i+2,j+2,15);
}
}
}


OutPut :
























0 comments:

Post a Comment