| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 522 人关注过本帖
标题:[分享]烟花程序
只看楼主 加入收藏
中山DJ肥仔
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2007-4-20
收藏
 问题点数:0 回复次数:1 
[分享]烟花程序

#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
#include <graphics.h>
#include <bios.h>
#include <stdlib.h>
#define PI 3.14159

void moon()
{
int x=50,y=50,n=30;
setcolor(YELLOW);
setfillstyle(1,YELLOW);
ellipse(x,y,0,360,n,n);
ellipse(x+n/2,y,90,270,n,n);
floodfill(x-n+3,y,YELLOW);
setcolor(BLACK);
circle(x,y,n);
circle(x+n/2,y,n);
}

void star(int x, int y)
{

int i,a;
int n=5;
int x1[5],y1[5],x2[5],y2[5];
setcolor(YELLOW);


for (i=0;i<5;i++)
{

x1[i]=x+n*cos(i*72*PI/180);
y1[i]=y+n*sin(i*72*PI/180);
x2[i]=x+n/2*cos(i*72*PI/180+PI/5);
y2[i]=y+n/2*sin(i*72*PI/180+PI/5);
}

for(i=0;i<5;i++)
{
a=i+1;
if(a>4) a=0;
line(x1[i],y1[i],x2[i],y2[i]);
line(x2[i],y2[i],x1[a],y1[a]);
}
}

void drawstar()
{
int a[]={70,250,190,400,150};
int b[]={43,27,38,79,90},i;

setfillstyle(1,14);
for(i=0;i<5;i++)
{


star(a[i],b[i]);
floodfill(a[i],b[i],YELLOW);

}
}

void starflower()
{
int i=0,j,n=60,n1=2;
int x=200,y=200,size=100;
int cover=0;
int delay1=5000;
int wid,hei;
int px,py;
int color=9;

while(!kbhit())

{
if(i<size)
{
for(j=0;j<n;j++)
{
px=x+i*cos(j*360/n*PI/180);
py=y+i*sin(j*360/n*PI/180);
putpixel(px,py,rand()%16);
putpixel(px-1,py,color);
putpixel(px,py+1,color);
putpixel(px+1,py-1,YELLOW);
putpixel(px,py-1,YELLOW);
putpixel(px+1,py,RED);
putpixel(px+1,py+1,RED);
}
}

if(i>size && cover<size)
{
setcolor(BLACK);
circle(x,y,cover++);
delay1=1000;

}
if(cover==size)
{
i=0;
x=50+rand()%550;
y=rand()%400;
cover=0;
color=rand()%16;

size=50+rand()%250;
delay1=10000;
clearviewport();
drawstar();
moon();
}
i+=n1;
delay(delay1);

}

}
main()

{
int i,j,k;
int gdriver = DETECT, gmode;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&gmode,"");
drawstar();
moon();
starflower();
}

搜索更多相关主题的帖子: 烟花 分享 
2007-04-20 23:29
快速回复:[分享]烟花程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013696 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved