Aween

向.NET进发

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

 

#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);
}

posted on 2006-03-02 21:59  Aween's Blog  阅读(265)  评论(0编辑  收藏  举报