c 语言实现的简单屏幕烟花程序
2008-08-03 00:51
363 查看
#include "stdlib.h"
#include "graphics.h"
#include "stdio.h"
#include "math.h"
#include "conio.h "
#define PI 3.1425926
main()
{
int gdriver=DETECT,gmode,errorcode;
int a[10],b[10],x,y,c,r,i,j,t;
double rad = 0.0;
/* initialize graphics and local variables */
initgraph(&gdriver , &gmode ,"");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error : %s/n",grapherrormsg(errorcode));
printf("Please any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
randomize();
for(;!kbhit();)
{
x=rand()%500+100; /*随机中心坐标*/
y=rand()%300+100;
/* */
for(r = 0 ;r <= 8 ; r++ ) /*烟花的大小设定*/
{
for(i = 0,rad = 0.0 ; rad < 2*PI; rad += 0.78 ) /*设定坐标*/
{
a[i++] = x + (int)r *10* cos(rad);
b[ i ] = y + (int)r *10* sin(rad);
}
t = i;
for(i=1;i<t;i++)
{
c=rand()%13+1; /*各点的颜色随机*/
setcolor(c); /*功能:将当前图形屏幕的当前笔画颜色置为color.*/
circle(a[i],b[i],1);/* a[i],b[i] 为圆心 1 为半径 画圆 */
}
delay(10000);
delay(10000);
cleardevice();
/**************************************
*函数名: cleardevice *
*功 能: 清除图形屏幕 *
*用 法: void far cleardevice(void); *
* *
**************************************/
/*各点的坐标变换*/
}
}
getch();
closegraph();
/*
函数名: closegraph
功 能: 关闭图形系统
用 法: void far closegraph(void);
*/
}
#include "graphics.h"
#include "stdio.h"
#include "math.h"
#include "conio.h "
#define PI 3.1425926
main()
{
int gdriver=DETECT,gmode,errorcode;
int a[10],b[10],x,y,c,r,i,j,t;
double rad = 0.0;
/* initialize graphics and local variables */
initgraph(&gdriver , &gmode ,"");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error : %s/n",grapherrormsg(errorcode));
printf("Please any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
randomize();
for(;!kbhit();)
{
x=rand()%500+100; /*随机中心坐标*/
y=rand()%300+100;
/* */
for(r = 0 ;r <= 8 ; r++ ) /*烟花的大小设定*/
{
for(i = 0,rad = 0.0 ; rad < 2*PI; rad += 0.78 ) /*设定坐标*/
{
a[i++] = x + (int)r *10* cos(rad);
b[ i ] = y + (int)r *10* sin(rad);
}
t = i;
for(i=1;i<t;i++)
{
c=rand()%13+1; /*各点的颜色随机*/
setcolor(c); /*功能:将当前图形屏幕的当前笔画颜色置为color.*/
circle(a[i],b[i],1);/* a[i],b[i] 为圆心 1 为半径 画圆 */
}
delay(10000);
delay(10000);
cleardevice();
/**************************************
*函数名: cleardevice *
*功 能: 清除图形屏幕 *
*用 法: void far cleardevice(void); *
* *
**************************************/
/*各点的坐标变换*/
}
}
getch();
closegraph();
/*
函数名: closegraph
功 能: 关闭图形系统
用 法: void far closegraph(void);
*/
}
相关文章推荐
- 你知道的,javascript语言的执行环境是"单线程模式",这种模式的好处是实现起来比较简单,执行环境相对单纯;坏处是只要有一个任务耗时很长,后面的任务都必须排队等着,会拖延整个程序的执行,因此很多时候需要进行“异步模式”,请列举js异步编程的方法。
- Winform程序多语言国际化实现的简单方法
- 不带有界面的简单的计算器小程序(Java语言实现)
- GO语言实现的简单“木马”小程序
- java语言实现月食过程的简单小程序
- Thrift 简单实现C#通讯服务程序 (跨语言 MicroServices)
- Winform程序多语言国际化实现的简单方法
- [导入]Winform程序多语言国际化实现的简单方法
- C# 窗口实现Win7简单屏幕泡泡保护程序 和实现聊天窗口震动
- 使用UDP实现一个简单的聊天程序。
- ASP实现小偷程序原理和简单示例
- 通过pyrUp和pyrDown实现图像缩放的简单程序
- java写一个程序,实现从文件中读出文件内容,并将其打印在屏幕当中,并标注上行号
- 《Go语言入门》第一个Go语言Web程序——简单的Web服务器
- .NET程序实现"多语言"
- 数据结构(Java语言)——Stack简单实现
- 数据结构(Java语言)——LinkedList简单实现
- Go语言内部rpc简单实例,实现python调用go的jsonrpc小实例
- 一些简单程序的函数实现
- 一个简单的 C# 语言编写的 WIN32 程序