#include <stdio.h>//没写完
#include <conio.h>
#include <windows.h>
#include <mmsystem.h>
#pragma comment(lib,"WinMM.lib")
#include <string.h>
#include <math.h>
#include <time.h>
#include <graphics.h>
#define PI 3.1415926
#define WIDTH 640
#define HEIGHT 480
#define MAXSTAR 100
struct STAR
{
int x;
int y;
double step;
int color;
}star[MAXSTAR];
void frame();
void InitStar(int);
void MoveStar(int);
int main()
{
PlaySound("k:\\resource\\刘三姐.wav",NULL,SND_FILENAME|SND_ASYNC|SND_LOOP);
initgraph(WIDTH,HEIGHT,NOMINIMIZE);
setbkcolor(WHITE);
cleardevice();
frame();
getch();
closegraph();
return 0;
}
void frame()
{
int i;
srand((unsigned)time(NULL));
setcolor(RGB(rand()%225,rand()%225,rand()%225));
rectangle(0,0,WIDTH-1,HEIGHT-1);
setcolor(CYAN);
line(0,49,WIDTH-1,49);
outtextxy(1,1,"PRESENT-SCORE:");
outtextxy(1,16,"HIGHEST-SCORE:");//默认高度13
outtextxy(1,30," START-TIMES:");
line(120,0,120,49);
line(170,0,170,49);
outtextxy(121,1,"888888");
line(0,16,170,16);
line(0,30,170,30);
//第二条框
setfillstyle(BS_SOLID);
setfillcolor(LIGHTGREEN);
fillrectangle(0,50,639,69);
//彩虹
float H = 190; // 色相
float S = 1; // 饱和度
float L = 0.7f; // 亮度
for(int y = 70; y < 480; y++)
{
L += 0.0005f;
setlinecolor( HSLtoRGB(H, S, L) );
line(0, y, 639, y);
}
// 画彩虹(通过色相逐渐增加)
H = 0;
S = 1;
L = 0.5f;
setlinestyle(PS_SOLID, 2); // 设置线宽为 2
for(int r = 400; r > 344; r--)
{
H += 5;
setlinecolor( HSLtoRGB(H, S, L) );
circle(500, 480, r);
}
//星空
setbkcolor(BLACK);
setfillcolor(BLACK);
solidrectangle(170,1,639,49);
for(i=0;i<MAXSTAR;i++)
{
InitStar(i);
star[i].x = rand()%(640-170)+170;
}
while(true)
{
for(i=0;i<MAXSTAR;i++)
MoveStar(i);
Sleep(40);
}
}
void InitStar(int i)
{
star[i].x = 171;
star[i].y = rand()%50;
star[i].step = (rand()%5000)/1000.0+1;
star[i].color = (int)(star[i].step * 255 / 6.0 + 0.5); // 速度越快,颜色越亮
star[i].color = RGB(star[i].color, star[i].color, star[i].color);
}
void MoveStar(int i)
{
putpixel((int)star[i].x, star[i].y, 0);
star[i].x += star[i].step;
if (star[i].x > 639)
InitStar(i);
putpixel((int)star[i].x, star[i].y, star[i].color);
}