Well i have created another silly game.. Something similar to PAC man. But here the AI(Artifical Intelegence) i have used is so dumb. Is there any way you can make the circles more intelegent in capturing the users circle instead of just blindly followin it..

Here is the source.. User num pad key 4,6,8,and 2 to move around. Still in my previous question the problem of program freezing while input has not been completely been solved. The same problem occurs here..

# include <graphics.h>

# include <conio.h>

# include <dos.h>

# include <iostream.h>

# include <stdlib.h>

int x=10,y=10,x1=100,y1=100,x2=300,y2=300;

int val;

inig()

{

int gdriver = DETECT, gmode, errorcode;

initgraph(&gdriver, &gmode, "");

}

calc()

{

if(x1>x)

x1--;

if(x1<x)

x1++;

if(y1>y)

y1--;

if(y1<y)

y1++;

}

calc1()

{

if(x2>x)

x2=x2-2;

if(x2<x)

x2=x2+2;

if(y2>y)

y2=y2-2;

if(y2<y)

y2=y2+2;

}

catch()

{

if((x==x1 && y==y1) || (x==x2 && y==y2))

{

for(int q=0;q<100;q++)

{

circle(x,y,q);

delay(5);

}

cout<<" Game Over";

getche();

exit(0);

}

}

start()

{

prog:

clearviewport();

circle(x,y,10);

circle(x1,y1,5);

circle(x2,y2,15

);

val=getche();

if(val==52)

x=x-5;

if(val==54)

x=x+5;

if(val==50)

y=y+5;

if(val==56)

y=y-5;

if(val==27)

exit(0);

calc();

calc1();

catch();

goto prog;

}

main()

{

clrscr();

inig();

start();

}