欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程语言 > python >内容正文

python

python画烟花的代码_电脑怎么用代码画烟花?

发布时间:2024/9/27 python 54 豆豆
生活随笔 收集整理的这篇文章主要介绍了 python画烟花的代码_电脑怎么用代码画烟花? 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

内个,我是化学专业的……

回忆了一下,框架是这个:

#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

{

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

}

总结

以上是生活随笔为你收集整理的python画烟花的代码_电脑怎么用代码画烟花?的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。