








#include"stdio.h"
#include "math.h"
#include "conio.h"
#include "stdlib.h"
#include "graphics.h"
#define NUMBER 8
#define PI 3.14
#define STEP 8
#define STRING "2000"
#define MAXSIZE 24
#define DEFSIZE 16
struct FLY_H
{
int x,y;
int size;
char font;
int color;
int rale;
};
void fly(struct FLY_H *f);
main()
{
int drive=VGA,mode=VGAHI;
int i;
struct FLY_H f[NUMBER];
registerbgidriver(EGAVGA_driver);
initgraph(&drive,&mode,"");
randomize();
for(i=0;i<NUMBER;i++)
{
f[i].x=random(getmaxx()/3+getmaxx()/3);
f[i].y=random(getmaxy()/3+getmaxy()/3);
f[i].color=random(15)+1;
f[i].font=random(4)+1;
f[i].size=1;
f[i].rale=random(360);
}
while(bioskey(1)!=0x011b)
for(i=0;i<NUMBER&&bioskey(1)!=0x011b;i++)
{
fly(&f[i]);
if(bioskey(1))
{
if(bioskey(1)!=0x011b)
getch();
}
}
closegraph();
}
void fly(struct FLY_H *f)
{ setcolor(getbkcolor());
settextstyle(f->font,HORIZ_DIR,0);
setusercharsize(f->size,DEFSIZE,f->size,DEFSIZE);
outtextxy(f->x,f->y,STRING);
if(f->size+1<=MAXSIZE)
f->size++;
f->x+=STEP *cos((float) f->rale/180.0*PI);
f->y+=STEP*sin((float)f->rale/180.0*PI);
if(f->x>getmaxx()||f->y>getmaxy()||f->x+f->size*strlen(STRING)<0||f->y+f->size*strlen(STRING)<0)
{ f->x=random(getmaxx()/3+getmaxx()/3);
f->y=random(getmaxy()/3+getmaxy()/3);
f->color=random(15)+1;
f->font=random(4)+1;
f->size=1;
f->rale=random(360);
}
setcolor(f->color);
settextstyle(f->font,HORIZ_DIR,0);
setusercharsize(f->size,DEFSIZE,f->size,DEFSIZE);
outtextxy(f->x,f->y,STRING);
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。