喔哇,
創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供丹徒網(wǎng)站建設(shè)、丹徒做網(wǎng)站、丹徒網(wǎng)站設(shè)計(jì)、丹徒網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)與制作、丹徒企業(yè)網(wǎng)站模板建站服務(wù),10余年丹徒做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。
都是啥子年代了,
還食古不化,
在觸摸屏幕用手指劃動(dòng)而產(chǎn)生燃放煙花的虛擬圖像效果,
早就被時(shí)代徹底底拋棄了??!
現(xiàn)在都是在空中一劃,根據(jù)手勢,根據(jù)手勢的空間運(yùn)動(dòng),
立即就是實(shí)際來真格的,
真實(shí)、震撼、空間大爆炸、場面駭人、驚天動(dòng)地。
無接觸,
摒棄虛擬的虛假玩意兒。
你吹一口氣,
燃放裝置就噴出一股火焰。
機(jī)械加工能力和基礎(chǔ)強(qiáng)勁的,
產(chǎn)生1米邊長見方立體焰火造型,
與產(chǎn)生100米見方焰火造型的設(shè)備是通用的。
你與情侶自拍“刷臉”就立即產(chǎn)生肖像燃放造型,
其詳細(xì)的工程技術(shù)細(xì)節(jié),
早就有中英文對照的文本,
照著去做就可以了,
無需操作機(jī)床加工的人員,
去“進(jìn)一步研究思考”、去開展“創(chuàng)造性的工作”。
import?java.awt.*;
import?java.applet.*;
import?java.awt.event.*;
import?javax.swing.*;
public?class?Fireworks?extends?Applet?implements?MouseListener,?Runnable?{
int?x,?y;//記錄鼠標(biāo)點(diǎn)擊的坐標(biāo)
int?top,?point;//好像沒用到
public?void?init()?{
x?=?0;
y?=?0;
setBackground(Color.black);//?設(shè)置背景色為黑色
addMouseListener(this);//添加鼠標(biāo)監(jiān)聽
}
public?void?paint(Graphics?g)?{
}
public?static?void?main(String?args[])?{
Fireworks?applet?=?new?Fireworks();
JFrame?frame?=?new?JFrame("TextAreaNew");
frame.addWindowListener(new?WindowAdapter()?{
public?void?windowClosing(WindowEvent?e)?{//右上角的叉
System.exit(0);
}
});
frame.add(applet,?BorderLayout.CENTER);
frame.setSize(800,?400);//程序的框框大小
applet.init();
applet.start();
frame.setVisible(true);//
}
public?void?run()?{
//?變量初始化
Graphics?g1;
g1?=?getGraphics();//這是畫筆,得到一個(gè)畫筆
int?y_move,?y_click,?x_click;
int?v;//用于計(jì)算等待的時(shí)間
x_click?=?x;
y_click?=?y;//把點(diǎn)擊的坐標(biāo)保存下來,因?yàn)槠渌€程會去改這兩個(gè)坐標(biāo)。
y_move?=?400;//用來計(jì)算變動(dòng)的那個(gè)點(diǎn),現(xiàn)在是屏幕的最大高度
v?=?3;
int?r,?g,?b;
while?(y_move??y_click)//如果點(diǎn)擊的位置小于最大高度。
{
g1.setColor(Color.black);//畫筆設(shè)成黑色
g1.fillOval(x_click,?y_move,?5,?5);//畫圓,圓點(diǎn)在點(diǎn)擊的X軸,程序界面的最高點(diǎn),長為5,寬為5
y_move?-=?5;//最高點(diǎn)-5
r?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;
g?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;
b?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;//rgb是光的三原色,這個(gè)就是煙花產(chǎn)生的顏色,這里定義成隨機(jī)的,但在一個(gè)范圍里
g1.setColor(new?Color(r,?g,?b));//把畫筆改成那個(gè)顏色
g1.fillOval(x_click,?y_move,?5,?5);//畫一個(gè)這樣的圓
for?(int?j?=?0;?j?=?10;?j++)?{
if?(r??55)
r?-=?20;
if?(g??55)
g?-=?20;
if?(b??55)
b?-=?20;
g1.setColor(new?Color(r,?g,?b));
g1.fillOval(x_click,?y_move?+?j?*?5,?5,?5);//這一段都是改變顏色,然后畫圓的
}
g1.setColor(Color.black);
g1.fillOval(x_click,?y_move?+?5?*?10,?5,?5);//把上一次畫的彩色圓,用黑色畫一遍,就能讓它消失在背景里
try?{
Thread.currentThread().sleep(v++);//讓程序等一下,讓你看到效果,不然畫完的東西一下就不見了,你看不清。
}?catch?(InterruptedException?e)?{
}
}//上面這段代碼是煙花的升上去的那一串東西的效果
for?(int?j?=?12;?j?=?0;?j--)?{
g1.setColor(Color.black);
g1.fillOval(x_click,?y_move?+?(j?*?5),?5,?5);
try?{
Thread.currentThread().sleep((v++)?/?3);
}?catch?(InterruptedException?e)?{
}
}//讓最后的那串東西的點(diǎn)消失
y_move?=?400;
g1.setColor(Color.black);
while?(y_move??y_click)?{
g1.fillOval(x_click?-?2,?y_move,?9,?5);
y_move?-=?5;
}//這段不太清楚是干什么的,我把它去掉,看不出效果的變化
v?=?15;
for?(int?i?=?0;?i?=?25;?i++)?{
r?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;
g?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;
b?=?(((int)?Math.round(Math.random()?*?4321))?%?200)?+?55;
g1.setColor(new?Color(r,?g,?b));
g1.drawOval(x_click?-?3?*?i,?y_click?-?3?*?i,?6?*?i,?6?*?i);
if?(i??23)?{
g1.drawOval(x_click?-?3?*?(i?+?1),?y_click?-?3?*?(i?+?1),
6?*?(i?+?1),?6?*?(i?+?1));
g1.drawOval(x_click?-?3?*?(i?+?2),?y_click?-?3?*?(i?+?2),
6?*?(i?+?2),?6?*?(i?+?2));
}//上面這段是畫爆炸的效果
try?{
Thread.currentThread().sleep(v++);//停一下,看效果
}?catch?(InterruptedException?e)?{
}
g1.setColor(Color.black);
g1.drawOval(x_click?-?3?*?i,?y_click?-?3?*?i,?6?*?i,?6?*?i);//然后畫黑圈,相當(dāng)于讓彩圈消失。
}
}
public?void?mousePressed(MouseEvent?e)?{//點(diǎn)擊從這里開始~~~~~~~~~~~~~~
x?=?e.getX();
y?=?e.getY();//得到鼠標(biāo)點(diǎn)擊的坐標(biāo)
Thread?one?=?new?Thread(this);//新建一個(gè)線程
one.start();//啟動(dòng)這個(gè)線程,到上面的run方法
one?=?null;//把這個(gè)線程置為空,讓它執(zhí)行完以后就釋放
}
如果你想一下自己寫要怎樣寫這個(gè)程序,就很容易理解這個(gè)程序了。
一直從下向上畫圓,然后把下面的圓擦掉,就能得到一個(gè)向上升的煙花效果,
爆炸效果就是先畫小圓再畫大圓,然后擦掉小圓,再擦掉大圓。
// Decompiled by DJ v2.9.9.60 Copyright 2000 Atanas Neshkov Date: 2003-1-8 9:49:09
// Home Page : - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: jhanabi.java
import java.applet.Applet;
import java.applet.AudioClip;
import java.awt.*;
import java.awt.image.MemoryImageSource;
import java.util.Random;
public class jhanabi extends Applet
implements Runnable
{
public jhanabi()
{
m_mouseX = 0;
m_mouseY = 0;
m_sleepTime = 5;
isError = false;
isInitialized = false;
rand = new Random();
bits = 10000;
bit_px = new double[bits];
bit_py = new double[bits];
bit_vx = new double[bits];
bit_vy = new double[bits];
bit_sx = new int[bits];
bit_sy = new int[bits];
bit_l = new int[bits];
bit_f = new int[bits];
bit_p = new int[bits];
bit_c = new int[bits];
ru = 50;
rv = 50;
}
public void init()
{
String s = getParameter("para_bits");
if(s != null)
bits = Integer.parseInt(s);
s = getParameter("para_max");
if(s != null)
bit_max = Integer.parseInt(s);
s = getParameter("para_blendx");
if(s != null)
ru = Integer.parseInt(s);
s = getParameter("para_blendy");
if(s != null)
rv = Integer.parseInt(s);
s = getParameter("para_sound");
if(s != null)
bit_sound = Integer.parseInt(s);
m_nAppX = size().width;
m_nAppY = size().height;
m_centerX = m_nAppX / 2;
m_centerY = m_nAppY / 2;
m_mouseX = m_centerX;
m_mouseY = m_centerY;
resize(m_nAppX, m_nAppY);
pixls = m_nAppX * m_nAppY;
pixls2 = pixls - m_nAppX * 2;
pix0 = new int[pixls];
offImage = new MemoryImageSource(m_nAppX, m_nAppY, pix0, 0, m_nAppX);
offImage.setAnimated(true);
dbImg = createImage(offImage);
for(int i = 0; i pixls; i++)
pix0[i] = 0xff000000;
sound1 = getAudioClip(getDocumentBase(), "firework.au");
sound2 = getAudioClip(getDocumentBase(), "syu.au");
for(int j = 0; j bits; j++)
bit_f[j] = 0;
isInitialized = true;
start();
}
public void run()
{
while(!isInitialized)
try
{
Thread.sleep(200L);
}
catch(InterruptedException interruptedexception) { }
do
{
for(int j = 0; j pixls2; j++)
{
int k = pix0[j];
int l = pix0[j + 1];
int i1 = pix0[j + m_nAppX];
int j1 = pix0[j + m_nAppX + 1];
int i = (k 0xff0000) 16;
int k1 = ((((l 0xff0000) 16) - i) * ru 8) + i;
i = (k 0xff00) 8;
int l1 = ((((l 0xff00) 8) - i) * ru 8) + i;
i = k 0xff;
int i2 = (((l 0xff) - i) * ru 8) + i;
i = (i1 0xff0000) 16;
int j2 = ((((j1 0xff0000) 16) - i) * ru 8) + i;
i = (i1 0xff00) 8;
int k2 = ((((j1 0xff00) 8) - i) * ru 8) + i;
i = i1 0xff;
int l2 = (((j1 0xff) - i) * ru 8) + i;
int i3 = ((j2 - k1) * rv 8) + k1;
int j3 = ((k2 - l1) * rv 8) + l1;
int k3 = ((l2 - i2) * rv 8) + i2;
pix0[j] = i3 16 | j3 8 | k3 | 0xff000000;
}
rend();
offImage.newPixels(0, 0, m_nAppX, m_nAppY);
try
{
Thread.sleep(m_sleepTime);
}
catch(InterruptedException interruptedexception1) { }
} while(true);
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(dbImg, 0, 0, this);
}
public void start()
{
if(isError)
return;
isRunning = true;
if(runner == null)
{
runner = new Thread(this);
runner.start();
}
}
public void stop()
{
if(runner != null)
{
runner.stop();
runner = null;
}
}
public boolean mouseMove(Event event, int i, int j)
{
m_mouseX = i;
m_mouseY = j;
return true;
}
public boolean mouseDown(Event event, int i, int j)
{
m_mouseX = i;
m_mouseY = j;
int k = (int)(rand.nextDouble() * 256D);
int l = (int)(rand.nextDouble() * 256D);
int i1 = (int)(rand.nextDouble() * 256D);
int j1 = k 16 | l 8 | i1 | 0xff000000;
int k1 = 0;
for(int l1 = 0; l1 bits; l1++)
{
if(bit_f[l1] != 0)
continue;
bit_px[l1] = m_mouseX;
bit_py[l1] = m_mouseY;
double d = rand.nextDouble() * 6.2800000000000002D;
double d1 = rand.nextDouble();
bit_vx[l1] = Math.sin(d) * d1;
bit_vy[l1] = Math.cos(d) * d1;
bit_l[l1] = (int)(rand.nextDouble() * 100D) + 100;
bit_p[l1] = (int)(rand.nextDouble() * 3D);
bit_c[l1] = j1;
bit_sx[l1] = m_mouseX;
bit_sy[l1] = m_nAppY - 5;
bit_f[l1] = 2;
if(++k1 == bit_max)
break;
}
if(bit_sound 1)
sound2.play();
return true;
}
public boolean mouseExit(Event event, int i, int j)
{
m_mouseX = i;
m_mouseY = j;
return true;
}
void rend()
{
boolean flag = false;
boolean flag1 = false;
boolean flag2 = false;
for(int k = 0; k bits; k++)
switch(bit_f[k])
{
default:
break;
case 1: // '\001'
bit_vy[k] += rand.nextDouble() / 50D;
bit_px[k] += bit_vx[k];
bit_py[k] += bit_vy[k];
bit_l[k]--;
if(bit_l[k] == 0 || bit_px[k] 0.0D || bit_py[k] 0.0D || bit_px[k] (double)m_nAppX || bit_py[k] (double)(m_nAppY - 3))
{
bit_c[k] = 0xff000000;
bit_f[k] = 0;
} else
if(bit_p[k] == 0)
{
if((int)(rand.nextDouble() * 2D) == 0)
bit_set((int)bit_px[k], (int)bit_py[k], -1);
} else
{
bit_set((int)bit_px[k], (int)bit_py[k], bit_c[k]);
}
break;
case 2: // '\002'
bit_sy[k] -= 5;
if((double)bit_sy[k] = bit_py[k])
{
bit_f[k] = 1;
flag2 = true;
}
if((int)(rand.nextDouble() * 20D) == 0)
{
int i = (int)(rand.nextDouble() * 2D);
int j = (int)(rand.nextDouble() * 5D);
bit_set(bit_sx[k] + i, bit_sy[k] + j, -1);
}
break;
}
if(flag2 bit_sound 0)
sound1.play();
}
void bit_set(int i, int j, int k)
{
int l = i + j * m_nAppX;
pix0[l] = k;
}
private int m_nAppX;
private int m_nAppY;
private int m_centerX;
private int m_centerY;
private int m_mouseX;
private int m_mouseY;
private int m_sleepTime;
private boolean isError;
private boolean m_isPaintFinished;
boolean isRunning;
boolean isInitialized;
Thread runner;
int pix0[];
MemoryImageSource offImage;
Image dbImg;
int pixls;
int pixls2;
Random rand;
int bits;
double bit_px[];
double bit_py[];
double bit_vx[];
double bit_vy[];
int bit_sx[];
int bit_sy[];
int bit_l[];
int bit_f[];
int bit_p[];
int bit_c[];
int bit_max;
int bit_sound;
int ru;
int rv;
AudioClip sound1;
AudioClip sound2;
}
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()%500+100; /*隨機(jī)中心坐標(biāo)*/
y=rand()%300+100;
for(r = 0 ;r = 8 ; r++? )? ? /*煙花的大小設(shè)定*/
{
for(i = 0,rad = 0.0 ; rad 2*PI; rad += 0.78 )? /*設(shè)定坐標(biāo)*/
{
a[i++] = x + (int)r *10* cos(rad);
b[ i ] = y + (int)r *10* sin(rad);
}
t = i;
for(i=1;it;i++)
{
c=rand()%13+1; /*各點(diǎn)的顏色隨機(jī)*/
setcolor(c);? ? ? ?/*功能:將當(dāng)前圖形屏幕的當(dāng)前筆畫顏色置為color.*/
circle(a[i],b[i],1);/* a[i],b[i] 為圓心 1 為半徑 畫圓 */
}
delay(10000);
delay(10000);
cleardevice();
函數(shù)名: cleardevice? ? ? ? ?
功? 能: 清除圖形屏幕?
用? 法: void far cleardevice(void);
}
}
getch();
closegraph();
函數(shù)名: closegraph
功? 能: 關(guān)閉圖形系統(tǒng)
用? 法: void far closegraph(void);
}
初始化煙花參數(shù)
void Init( int i )
{
// 分別為:煙花中心到圖片邊緣的最遠(yuǎn)距離、煙花中心到圖片左上角的距離 (x、y) 兩個(gè)分量
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; // 煙花中心坐標(biāo)
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; // 綻放時(shí)間間隔
Fire[i].t1 = timeGetTime();
Fire[i].r = 0; // 從 0 開始綻放
/**** 初始化煙花彈 *****/
Jet[i].x = -240; // 煙花彈左上角坐標(biāo)
Jet[i].y = -240;
Jet[i].hx = -240; // 煙花彈發(fā)射最高點(diǎn)坐標(biāo)
Jet[i].hy = -240;
Jet[i].height = 0; // 發(fā)射高度
Jet[i].t1 = timeGetTime();
Jet[i].dt = rand() % 10; // 發(fā)射速度時(shí)間間隔
Jet[i].n = 0; // 煙花彈閃爍圖片下標(biāo)
Jet[i].shoot = false; // 是否發(fā)射
}
文章名稱:java煙花編程代碼 煙花的編程代碼html
本文網(wǎng)址:http://jinyejixie.com/article8/dosggip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、手機(jī)網(wǎng)站建設(shè)、營銷型網(wǎng)站建設(shè)、、域名注冊、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)