输出子弹动态弹射,按任意键退出循环

问题遇到的现象和发生背景

img

img

问题相关代码,请勿粘贴截图

#include
#include
#include"EasyXPng.h"
#define WIDTH 560
#define HEIGHT 800

struct Bullet
{
IMAGE im_bullet;
float x,y;
float vx,vy;
float radius;
};

IMAGE im_bk,im_bullet;
Bullet bullet;

void startup()
{
loadimage(&im_bk,_T(".\background.png"));
loadimage(&im_bullet,_T(".\bullet.png"));
bullet.x=WIDTH/2;
bullet.y=HEIGHT/2;
bullet.vx=2;
bullet.vy=2;
bullet.im_bullet=im_bullet;
bullet.radius=im_bullet.getwidth()/2;

initgraph(WIDTH,HEIGHT);
BeginBatchDraw();

}

void show()
{
putimage(0,0,&im_bk);
putimagePng(bullet.x-bullet.radius,bullet.y-bullet.radius,
&bullet.im_bullet);
FlushBatchDraw();
Sleep(10);
}

void updateWithoutInput()
{
bullet.x+=bullet.vx;
bullet.y+=bullet.vy;
if(bullet.x<=0||bullet.x>=WIDTH)
bullet.vx=-bullet.vx;
if(bullet.y<=0||bullet.y>=HEIGHT)
bullet.vy=-bullet.vy;
}

int main()
{
startup();
while(1)
{
show();
updateWithoutInput();
if(_getch())
return 1;
else
return 0;

}
return 0;

}

我想要达到的结果

输出子弹动态弹射,按任意键退出循环。

img

图片补充

img

你这个不行?