飞机追逐小游戏,怎么让两个飞机追逐啊,救命。
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int i,j;
int x = 0;
int y = 5;
int x2=0;
int y2=5;
int velocity_x2 = 1;
int velocity_y2 = 1;
int velocity_x = 1;
int velocity_y = 1;
int left = 0;
int right = 20;
int top = 0;
int bottom = 10;
while (1)
{
x = x + velocity_x;
y = y + velocity_y;
x2=x2+velocity_x2;
y2=y2+velocity_y2;
system("cls"); // 清屏函数
// 输出飞机前的空行
for(i=0;i<x;i++)
printf("\n");
// 下面输出一个复杂的飞机图案
for (j=0;j<y;j++)
printf(" ");
printf("| *\n");
for (j=0;j<y;j++)
printf(" ");
printf("-----\n");
for (j=0;j<y;j++)
printf(" ");
printf("| * \n");
for(i=0;i<x2;i++)
printf("\n");
// 下面输出一个复杂的飞机图案
for (j=0;j<y2;j++)
printf(" ");
printf("| *\n");
for (j=0;j<y;j++)
printf(" ");
printf("-----\n");
for (j=0;j<y;j++)
printf(" ");
printf("| * \n");
for(i=0;i<x2;i++)
printf("\n");
Sleep(50); // 等待若干毫秒
if ((x==top)||(x==bottom))
velocity_x = -velocity_x;
if ((y==left)||(y==right))
velocity_y = -velocity_y;
if ((x2==top)||(x2==bottom))
velocity_x2 = -velocity_x2;
if ((y2==left)||(y2==right))
velocity_y2 = -velocity_y2;
}
return 0;
}