注
发布时间
阅读量:
阅读量
//基础动画三,更丰富的变化与帧率
#include <graphics.h>
#include <stdio.h>
void mainloop()
{
//x,y记录当前位置,dx,dy记录速度向量,r记录圆半径
int x = 0, y = 0, dx = 1, dy = 1, r = 100;
for ( ; is_run(); delay_fps(60) )
{
// todo: 逻辑更新
// 当前位置 + 速度
x += dx;
y += dy;
if (x < r) dx = 1; //碰左
if (y < r) dy = 1; //碰上
if (x >= ege::getwidth() - r) dx = -1; //碰右
if (y >= ege::getheight() - r) dy = -1; //碰下
// todo: 图形更新
cleardevice();
setcolor(GREEN);
setfillcolor(BLUE);
fillellipse(x, y,
全部评论 (0)
还没有任何评论哟~
