代码拉取完成,页面将自动刷新
#define _CRT_SECURE_NO_WARNINGS
#include<conio.h>
#include<graphics.h>
#include<conio.h>
#include<Windows.h>
#define High 480
#define Width 640
int main()
{
float ball_x, ball_y;
float ball_vx, ball_vy;
float radius;
initgraph(Width, High);
ball_x = Width / 2;
ball_y = High / 2;
ball_vx = 1;
ball_vy = 1;
radius = 20;
while (1)
{
setcolor(BLACK);
setfillcolor(BLACK);
fillcircle(ball_x, ball_y, radius);
ball_x = ball_x + ball_vx;
ball_y = ball_y + ball_vy;
if ((ball_x <= radius) || (ball_x >= Width - radius))
ball_vx = -ball_vx;
if ((ball_y <= radius) || (ball_y) >= High - radius)
ball_vy = -ball_vy;
setcolor(YELLOW);
setfillcolor(GREEN);
fillcircle(ball_x, ball_y, radius);
Sleep(8);
}
_getch();
closegraph();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。