當前位置:九游会j9娱乐平台-九游ag登录中心网址 » 編程軟體 » 變編程煙花

變編程煙花-九游会j9娱乐平台

發布時間: 2024-07-16 21:33:40

a. c語言編程煙花代碼簡單

c語言編程煙花代碼簡單如下:

#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()p0 100; /*隨機中心坐標州純*/

y=rand()00 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() 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);

}

初始化煙花參數

void init( int i )

{

// 分別為:煙花余族中心到圖片邊緣的最遠距離、煙花中心到圖片左上角的距離 (x、y) 兩個分量

int r[13] = { 120, 120, 155, 123, 130, 147, 138, 138, 130, 135, 140, 132, 155 };

int x[13] = { 120, 120, 110, 117, 110, 93, 102, 102, 110, 105, 100, 108, 110 };

int y[13] = { 120, 120, 85, 118, 120, 103, 105, 110, 110, 120, 120, 104, 85 };

/**** 初始化煙花 *****/

fire[i].x = 0; // 煙花中心坐標

fire[i].y = 0;

fire[i].width = 240; // 圖片寬

fire[i].height = 240; // 圖片高

fire[i].max_r = r[i]; // 最大半徑

fire[i].cen_x = x[i]; // 中心距左上角距離

fire[i].cen_y = y[i];

fire[i].show = false; // 是否綻放

fire[i].dt = 5; // 綻放時間間隔

fire[i].t1 = timegettime();

fire[i].r = 0; // 從 0 開始綻放

/**** 初始化煙花彈 *****/

jet[i].x = -240; // 煙花彈左上角坐標

jet[i].y = -240;

jet[i].hx = -240; // 煙花彈豎跡弊發射最高點坐標

jet[i].hy = -240;

jet[i].height = 0; // 發射高度

jet[i].t1 = timegettime();

jet[i].dt = rand() % 10; // 發射速度時間間隔

jet[i].n = 0; // 煙花彈閃爍圖片下標

jet[i].shoot = false; // 是否發射

}

熱點內容
matlab命令窗口和新建腳本 發布:2024-07-17 15:51:26 瀏覽:374
建ftp文件夾 發布:2024-07-17 15:51:26 瀏覽:954
魔獸撿物腳本 發布:2024-07-17 15:27:56 瀏覽:129
開發ip伺服器 發布:2024-07-17 15:24:42 瀏覽:386
安卓系統視頻製作哪個好用 發布:2024-07-17 15:10:47 瀏覽:210
androidapk結構 發布:2024-07-17 15:10:43 瀏覽:945
c語言指針的例子 發布:2024-07-17 15:08:01 瀏覽:768
linuxzcat 發布:2024-07-17 15:02:09 瀏覽:901
賓士編程嗎 發布:2024-07-17 14:57:08 瀏覽:853
硬碟加密硬體 發布:2024-07-17 14:51:05 瀏覽:836
网站地图