easyx小球移动

#define _CRT_SECURE_NO_WARNINGS 1


#include
#include

int main()
{
    int high = 480, wide = 640;
    float ball_x = wide / 2;
    float ball_y = high / 2;
    float radius = 20;
    float ball_vx = 3, ball_vy = 3;
    initgraph(wide, high);
    BeginBatchDraw();
    while(1)
    {
        setcolor(RED);
        setfillcolor(RGB(255,0,0));
        fillcircle(ball_x, ball_y, radius);
        FlushBatchDraw();
        Sleep(1);
        setcolor(BLACK);
        setfillcolor(BLACK);
        fillcircle(ball_x, ball_y, radius);
        ball_x += ball_vx;
        ball_y += ball_vy;
        if ((ball_x <= radius) || (ball_x >= wide - radius))
            ball_vx *= -1;
        if ((ball_y <= radius) || (ball_y >= high - radius))
            ball_vy *= -1;
    }
    EndBatchDraw();
}

你可能感兴趣的:(算法,数据结构,c语言,排序算法,c#)