سلام
#include <iostream>
#include <graphics.h>
using namespace std;
main()
{
initwindow(800,600);
int x[30]={200,180,160,140,120},y[30]={200,200,200,200,200},a=20,b=0;
int tool=4;
char ch=' ';
int xd=400,yd=400,fd=1,cl=15;
circle(xd,yd,8);
circle(xd,yd,6);
circle(xd,yd,4);
rectangle(49,49,710,510);
while(1)
{
setcolor(cl);
for(int i=0;i<=tool;i++)
circle(x[i],y[i],10);
delay(100);
if( (x[0]==xd)&&(y[0]==yd) )
{
cl--;
}
setcolor(0);
for(int i=0;i<=tool;i++)
circle(x[i],y[i],10);
if(kbhit())
ch=getch();
if(ch=='p')
tool++;
if(ch=='o')
tool--;
if((ch=='d')&&(a==0))
{
a=20;
b=0;
}
if((ch=='a')&&(a==0))
{
a=-20;
b=0;
}
if((ch=='w')&&(b==0))
{
a=0;
b=-20;
}
if((ch=='s')&&(b==0))
{
a=0;
b=20;
}
ch=' ';
for(int i=tool-1;i>=0;i--)
{
x[i+1]=x[i];
y[i+1]=y[i];
}
x[0]+=a;
y[0]+=b;
if(x[0]<60)
x[0]=700;
if(x[0]>700)
x[0]=60;
if(y[0]<60)
y[0]=500;
if(y[0]>500)
y[0]=60;
}
getch();
}