Все не надо... если кому интрересно, то вот консольный вариант:
QUOTE
#include
#include
#include
#include
void main()
{
int mas[20][40]={0};
int GunX, GunY;
int TargetX, TargetY;
int BulletX, BulletY;
int NaprX, NaprY;
int RastX, RastY;
randomize();
clrscr();
GunX=random(40);
GunY=random(20);
TargetX=random(40);
TargetY=random(20);
BulletX=GunX;
BulletY=GunY;
mas[GunY][GunX]=2;
mas[TargetY][TargetX]=3;
do
{
for(int y=0; y<20; y++)
{
for(int x=0; x<40; x++)
{
printf("%d",mas[y][x]);
}
printf("\n");
}
getch();
clrscr();
RastX=NaprX=GunX-TargetX;
RastY=NaprY=GunY-TargetY;
if(NaprY<0)
RastY*=-1;
if(NaprX<0)
RastX*=-1;
if(RastX>RastY)
{
if(NaprX<0)
BulletX++;
else
BulletX--;
BulletY=GunY+((BulletX-GunX)*(TargetY-GunY))/(TargetX-GunX);
}
else
{
if(NaprY<0)
BulletY++;
else
BulletY--;
BulletX=GunX+((BulletY-GunY)*(TargetX-GunX))/(TargetY-GunY);
}
mas[BulletY][BulletX]=1;
if(BulletX==TargetX && BulletY==TargetY)
break;
}
while(1);
puts("VSE");
getch();
}