#include
#include
#include
#include
struct Balloon
{
double x;
double y;
COLORREF color;
double vx = 0.0;
double vy = -((rand() % 10) / 10.0 + 0.1);//上升速度
};
void balloon_init(Balloon* ball, double x, double y)
{
ball->x = x;
ball->y = y;
ball->color = RGB(rand()%256,rand()%256,rand() % 256);//随机颜色
}
void balloon_(Balloon* ball)
{
ball->x = x;
ball->y = y;
ball->color;
{
setfillcolor(balls->color);//填充颜色
solidellipse(ball->x, ball->y, ball->x + 30, ball->y + 60); //实心椭圆
arc(ball->x + 5, ball->y + 5, ball->x + 30 - 5, ball->y + 60 - 5, 0, 1.2);//绘制圆弧高光
arc(ball->x, ball->y + 60, ball->x + 30 - 10, ball->y + 60 + 20, 0, 1.2);//绘制圆弧尾巴
}
void balloon_moveby(balloon * ball, double dx, double dy)
{
ball->x += dx;
ball->x += dy;
if (ball->y + 60 < 0)//气球循环
{
ball->y = getheight();
ball->x = rand() % getwidth();
}
}
int main()
{
initgraph(480, 480);//绘制窗口
srand(time(NULL));//时间随机
IMAGE bking;//插入图片
setbkmode(TRANSPARENT)
loadimage(&bking, "./program/OIP-C.jpg,480,480");
Balloon balls[15] = { 0 };
for (int i = 0; i < 15; i++)
{
balloon_init(balls + i, rand() % getwidth(), rand() % getheight());
balloon_draw(balls + i);
}
while (true)
{
beginbatchDraw();
cleardevice();//清屏
putimage(0, 0, &bking);//打印背景
for (int i = 0; i < 15; i++)
{
balloon_moveby(balls + i, 0, -1);//移动
balloon_draw(balls + i);
}
EndbatchDraw();
sleep(100);//延时
}
getchar();
return 0;
}
easyx用的#include <graphics.h>
错误太多了。
void balloon_(Balloon *ball)中x,y,ball->color;后面的{,
loadimage(&bking, "./program/OIP-C.jpg,480,480");改为loadimage(&bking, "./program/OIP-C.jpg",480,480);
等等根据提示改吧。