Easyx——基于easyx的c语言简单动画入门

在这里插入图片描述

#include <graphics.h>  //引入 easyx 图形库
#include <CONIO.H>
#include <math.h>

#define High 800
#define Width 640 
#define ball_radius 20
int main()
{
	int ball_y=High/2;
    int ball_x=Width/2;
    int ball_vx = 10;
	int ball_vy = 10;


	initgraph(Width,High);   //初始化画布。大小为640*480

	BeginBatchDraw();  //开始批量绘图

    while (1)
    {
    
	setcolor(YELLOW);  //圆的线条为黄色
	setfillcolor(GREEN);   //圆内部位绿色填充
	fillcircle(ball_x,ball_y,ball_radius);  //画圆,圆心(100,100) 半径20
	
	FlushBatchDraw();  将之前的绘图输出
	
	Sleep(20);

	setcolor(BLACK);
	setfillcolor(BLACK);
	fillcircle(ball_x,ball_y,200);

	ball_y = ball_y + ball_vy;
	ball_x = ball_x +ball_vx;

    if (ball_x<=ball_radius||ball_x >=Width - ball_radius)
        ball_vx = -1 * ball_vx;
	if (ball_y<=ball_radius||ball_y >=High - ball_radius)
	    ball_vy = -1 *ball_vy;

	}

	EndBatchDraw();  //结束批量绘制,并执行未完成的绘制任务。
	closegraph();
return 0;
}
  • 3
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值