飞机追逐小游戏,怎么让两个飞机追逐啊,救命。

weixin_44860788 2019-04-19 08:57:51
#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;
}
...全文
22 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

64,643

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧