#include <graphics.h>
#include <conio.h>
#include <dos.h>
#include<stdlib.h>
void err()
{
int gd, gm = DETECT;
initgraph(&gm, &gd, "");
}
class circ
{
void horizontal(int startx, int starty, int radius)
{
while(!kbhit())
{
int color = getcolor();
i++;
startx = startx + 1;
starty = starty + 1;
circle(startx, starty,
radius);
if (i> maxx)
i=0;
if ((i%20)==0)
{
setcolor(color);
}
if (startx <= 10 ||
starty <= 10 || startx >= maxx-10 || starty >= maxy-10 )
{
verticle(startx,
starty, radius);
}
}
}
void verticle(int startx, int starty, int radius)
{
while(!kbhit())
{
startx = startx - 1;
starty = starty + 1;
circle(startx, starty,
radius);
i++;
if ((i%30)==0)
setcolor(random(16));
if (startx <= 10 ||
starty <= 10 || startx >= maxx-10 || starty >=maxy-10)
{
back(startx,
starty, radius);
}
}
}
void back(int startx, int starty, int radius)
{
while(!kbhit())
{
startx = startx - 1;
starty = starty - 1;
i++;
circle(startx, starty,
radius);
if ((i%30)==0)
setcolor(random(16));
if
(startx <= 10 || starty <= 10 || startx >= maxx-10 || starty >=maxy-10)
{
forward(startx,
starty, radius);
}
}
}
void forward(int startx, int starty, int radius)
{
while(!kbhit())
{
startx
= startx + 1;
starty
= starty - 1;
i++;
circle(startx,
starty, radius);
if
((i%30)==0)
setcolor(random(16));
if
(startx <= 10 || starty <= 10 || startx >= maxx-10 || starty >=maxy-10)
{
horizontal(startx,
starty, radius);
}
}
}
public:
int maxx, maxy, prevx, prevy, left, top, right, bottom;
long int i;
circ(int startx, int starty, int radius)
{
err();
randomize();
i=5;
maxx = getmaxx();
maxy = getmaxy();
left = right = 0;
top = 0;
bottom = maxy;
prevx= startx-1;
prevy= starty-1;
horizontal(startx, starty, radius);
}
};
void main()
{
circ c(40, 67, 5);
closegraph();
}