这个代码适合表白用的:
代码如下:
#include<stdio.h>
#include<graphics.h> //第三方图形库
#include<time.h>
#include<conio.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
#define STAR_NUM 500
#define METEOR_NUM 100
struct Star //小星星
{
int x;
int y;
int r;
int speed; //速度
COLORREF color; //颜色
};
struct Meteor
{
int x;
int y;
int speed;
};
struct Star star[STAR_NUM];
struct Meteor meteor[METEOR_NUM];
/*@小星星*/
//初始化星星
void initStar(int i )
{
star[i].x = rand() % getwidth();
star[i].y = rand() % getheight();
star[i].r = rand() % 3 + 1;
star[i].speed = rand() % 5;
star[i].color = RGB(rand() % 256, rand() % 256, rand() % 256);
}
//绘制星星
void drawStar()
{
for (size_t i = 0; i < STAR_NUM; i++)
{
//putpixel(star[i].x, star[i].y, star[i].color);
setfillcolor(star[i].colo