当前位置:首页 > 代码 > 正文

烟花js代码(java烟花代码)

admin 发布:2022-12-19 12:18 116


本篇文章给大家谈谈烟花js代码,以及java烟花代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

《我的世界手机版》1.2烟花代码是什么

我的世界手机版1.2烟花代码是什么?我的世界烟花是新增的物品,玩家们不是很清楚它的代码。下面小编为大家分享。

我的世界手机版1.2烟花代码

这里的烟花指的是烟花火箭,其数据值DEC: 401 HEX: 191 BIN: 110010001。

实体id为:fireworks_rocket

如果在指令中要用到烟花火箭,只要输入上方的实体id就可以了。

flash烟花代码是什么?

var FireTimer:Timer=new Timer(1000);

FireTimer.addEventListener(TimerEvent.TIMER,addFire);

FireTimer.start();

var tempRo:Number;

function addFire(e:TimerEvent):void

{

var X:Number=Math.random()*550;

var Y:Number=Math.random()*400;

var color:uint=0xffffff* Math.random();

trace(color.toString());

for(var i:int=0;i100;i++)

{

var mc :MovieClip=new MovieClip();//定义一个影片剪辑

mc.graphics.beginFill(color);//影片剪辑的颜色

mc.graphics.drawCircle(0,0,4+3* Math.random());//绘制随机大小的圆

mc.graphics.endFill();

addChild(mc);

mc.x=X;

mc.y=Y;

mc.scaleX=mc.scaleY=0.4+Math.random()*0.6;

tempRo=Math.random()*360/180;

mc.spdX=Math.random()*10*Math.sin(tempRo)*Math.pow(-1,Math.floor(Math.random()*100)%2);

mc.spdY=Math.random()*10*Math.cos(tempRo)*Math.pow(-1,Math.floor(Math.random()*100)%2);

mc.addEventListener(Event.ENTER_FRAME,FireMove);

}

}

function FireMove(e:Event):void

{

var obj:Object=e.target;

obj.x+=obj.spdX;

obj.y+=obj.spdY;

obj.alpha-=0.05;

if(obj.alpha=0)

{

obj.removeEventListener(Event.ENTER_FRAME,FireMove);

}

}

新建一个AS3文档,把这些代码放到第一帧,CTRL+ENTER,OK了,烟花就出现了!这是我自己写的,你可以看一下。效果有的,只是不怎么好看。

烟花代码的格式是什么

烟花代码的格式是#include "stdlib.h"。

表述不清,没指明是什么的代码。代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。

代码设计的原则包括惟一确定性、标准化和通用性、可扩充性与稳定性、便于识别与记忆、力求短小与格式统一以及容易修改等。

Linux版本:

当前安装有Linux操作系统,数据中RedHatFedora占据绝对优势——Linux使用者使用该版本占总数的49.49%。Fedora是RedHat推出的重要的一款Linux版本,在每个fedora版本中都是集成最新的Linux软件,特别是服务端软件。

排在第二位的是Ubuntu,受支持数占到总数的23.92%;第三位的是SuSE占9.09%,接下来是Debian,使用率为5.92%。在这里面令人期待的中国本土Linux的让人大失所望。使用率仅占5.16%,几乎只有RedHatFedora的十分之一。

编一个鼠标点击放烟花的程序

楼上的不对,,,晕,,乱来。

把这个文件下下来。,把下面的代码加到你网页下,注意jhanabi.class的路径和网页一个路径的下面就不用改了。

applet height=330 width=800 align=middle code=jhanabi.class

param name="para_bits" value="10000"

param name="para_max" value="150"

param name="para_blendx" value="50"

param name="para_blendy" value="50"

param name="para_sound" value="2"

param name="width" value="800"

param name="align" value="baseline"

param name="code" value="jhanabi.class"

param name="codeBase" value="./"

param name="height" value="330"

/applet

如何用javascript做出点击屏幕产生烟花效果

!DOCTYPE html

!-- saved from url= --

html

headmeta http-equiv="Content-Type" content="text/html; charset=UTF-8"

meta content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"

meta name="apple-mobile-web-app-capable" content="yes"

meta name="apple-mobile-web-app-status-bar-style" content="black"

title烟花/title

style type="text/css"

html,body{height:100%;margin:0;padding:0}

ul,li{text-indent:0;text-decoration:none;margin:0;padding:0}

img{border:0}

body{background-color:#000;color:#999;font:100%/18px helvetica, arial, sans-serif}

canvas{cursor:crosshair;display:block;left:0;position:absolute;top:0;z-index:20}

#header img{width:100%; height:20%;}

#bg img{width:100%; height:80%;}

#header,#bg{position:fixed;left:0;right:0;z-index:10}

#header{top:0}

#bg{position:fixed;z-index:1;}

audio{position:fixed;display:none;bottom:0;left:0;right:0;width:100%;z-index:5}

/style

link rel="shortcut icon" type="image/x-icon" href=""

style type="text/css"/stylestyle id="style-1-cropbar-clipper"

.en-markup-crop-options {

    top: 18px !important;

    left: 50% !important;

    margin-left: -100px !important;

    width: 200px !important;

    border: 2px rgba(255,255,255,.38) solid !important;

    border-radius: 4px !important;

}

.en-markup-crop-options div div:first-of-type {

    margin-left: 0px !important;

}

#.bg {

background-color: black;

}

/style

/head

body

div id="bg"/div

script src=""/script

script type="text/javascript"

$(function(){

var Fireworks = function(){

var self = this;

var rand = function(rMi, rMa){return ~~((Math.random()*(rMa-rMi+1))+rMi);}

var hitTest = function(x1, y1, w1, h1, x2, y2, w2, h2){return !(x1 + w1  x2 || x2 + w2  x1 || y1 + h1  y2 || y2 + h2  y1);};

window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();

self.init = function(){ 

self.canvas = document.createElement('canvas');             

self.canvas.width = self.cw = $(window).innerWidth();

self.canvas.height = self.ch = $(window).innerHeight();         

self.particles = [];    

self.partCount = 150;

self.fireworks = [];    

self.mx = self.cw/2;

self.my = self.ch/2;

self.currentHue = 30;

self.partSpeed = 5;

self.partSpeedVariance = 10;

self.partWind = 50;

self.partFriction = 5;

self.partGravity = 1;

self.hueMin = 0;

self.hueMax = 360;

self.fworkSpeed = 4;

self.fworkAccel = 10;

self.hueVariance = 30;

self.flickerDensity = 25;

self.showShockwave = true;

self.showTarget = false;

self.clearAlpha = 25;

$(document.body).append(self.canvas);

self.ctx = self.canvas.getContext('2d');

self.ctx.lineCap = 'round';

self.ctx.lineJoin = 'round';

self.lineWidth = 1;

self.bindEvents();          

self.canvasLoop();

self.canvas.onselectstart = function() {

return false;

};

};      

self.createParticles = function(x,y, hue){

var countdown = self.partCount;

while(countdown--){

var newParticle = {

    x: x,

    y: y,

    coordLast: [

        {x: x, y: y},

        {x: x, y: y},

        {x: x, y: y}

    ],

    angle: rand(0, 360),

    speed: rand(((self.partSpeed - self.partSpeedVariance) = 0) ? 1 : self.partSpeed - self.partSpeedVariance, (self.partSpeed + self.partSpeedVariance)),

    friction: 1 - self.partFriction/100,

    gravity: self.partGravity/2,

    hue: rand(hue-self.hueVariance, hue+self.hueVariance),

    brightness: rand(50, 80),

    alpha: rand(40,100)/100,

    decay: rand(10, 50)/1000,

    wind: (rand(0, self.partWind) - (self.partWind/2))/25,

    lineWidth: self.lineWidth

};              

self.particles.push(newParticle);

}

};

self.updateParticles = function(){

var i = self.particles.length;

while(i--){

var p = self.particles[i];

var radians = p.angle * Math.PI / 180;

var vx = Math.cos(radians) * p.speed;

var vy = Math.sin(radians) * p.speed;

p.speed *= p.friction;

                

p.coordLast[2].x = p.coordLast[1].x;

p.coordLast[2].y = p.coordLast[1].y;

p.coordLast[1].x = p.coordLast[0].x;

p.coordLast[1].y = p.coordLast[0].y;

p.coordLast[0].x = p.x;

p.coordLast[0].y = p.y;

p.x += vx;

p.y += vy;

p.y += p.gravity;

p.angle += p.wind;              

p.alpha -= p.decay;

if(!hitTest(0,0,self.cw,self.ch,p.x-p.radius, p.y-p.radius, p.radius*2, p.radius*2) || p.alpha  .05){                  

    self.particles.splice(i, 1);    

}

};

};

self.drawParticles = function(){

var i = self.particles.length;

while(i--){

var p = self.particles[i];                          

var coordRand = (rand(1,3)-1);

self.ctx.beginPath();                               

self.ctx.moveTo(Math.round(p.coordLast[coordRand].x), Math.round(p.coordLast[coordRand].y));

self.ctx.lineTo(Math.round(p.x), Math.round(p.y));

self.ctx.closePath();               

self.ctx.strokeStyle = 'hsla('+p.hue+', 100%, '+p.brightness+'%, '+p.alpha+')';

self.ctx.stroke();              

if(self.flickerDensity  0){

    var inverseDensity = 50 - self.flickerDensity;                  

    if(rand(0, inverseDensity) === inverseDensity){

        self.ctx.beginPath();

        self.ctx.arc(Math.round(p.x), Math.round(p.y), rand(p.lineWidth,p.lineWidth+3)/2, 0, Math.PI*2, false)

        self.ctx.closePath();

        var randAlpha = rand(50,100)/100;

        self.ctx.fillStyle = 'hsla('+p.hue+', 100%, '+p.brightness+'%, '+randAlpha+')';

        self.ctx.fill();

    }   

}

};

};

self.createFireworks = function(startX, startY, targetX, targetY){

var newFirework = {

x: startX,

y: startY,

startX: startX,

startY: startY,

hitX: false,

hitY: false,

coordLast: [

    {x: startX, y: startY},

    {x: startX, y: startY},

    {x: startX, y: startY}

],

targetX: targetX,

targetY: targetY,

speed: self.fworkSpeed,

angle: Math.atan2(targetY - startY, targetX - startX),

shockwaveAngle: Math.atan2(targetY - startY, targetX - startX)+(90*(Math.PI/180)),

acceleration: self.fworkAccel/100,

hue: self.currentHue,

brightness: rand(50, 80),

alpha: rand(50,100)/100,

lineWidth: self.lineWidth

};          

self.fireworks.push(newFirework);

};

self.updateFireworks = function(){

var i = self.fireworks.length;

while(i--){

var f = self.fireworks[i];

self.ctx.lineWidth = f.lineWidth;

vx = Math.cos(f.angle) * f.speed,

vy = Math.sin(f.angle) * f.speed;

f.speed *= 1 + f.acceleration;              

f.coordLast[2].x = f.coordLast[1].x;

f.coordLast[2].y = f.coordLast[1].y;

f.coordLast[1].x = f.coordLast[0].x;

f.coordLast[1].y = f.coordLast[0].y;

f.coordLast[0].x = f.x;

f.coordLast[0].y = f.y;

if(f.startX = f.targetX){

    if(f.x + vx = f.targetX){

        f.x = f.targetX;

        f.hitX = true;

    } else {

        f.x += vx;

    }

} else {

    if(f.x + vx = f.targetX){

        f.x = f.targetX;

        f.hitX = true;

    } else {

        f.x += vx;

    }

}

if(f.startY = f.targetY){

    if(f.y + vy = f.targetY){

        f.y = f.targetY;

        f.hitY = true;

    } else {

        f.y += vy;

    }

} else {

    if(f.y + vy = f.targetY){

        f.y = f.targetY;

        f.hitY = true;

    } else {

        f.y += vy;

    }

}               

if(f.hitX  f.hitY){

    self.createParticles(f.targetX, f.targetY, f.hue);

    self.fireworks.splice(i, 1);

    

}

};

};

self.drawFireworks = function(){

var i = self.fireworks.length;

self.ctx.globalCompositeOperation = 'lighter';

while(i--){

var f = self.fireworks[i];      

self.ctx.lineWidth = f.lineWidth;

var coordRand = (rand(1,3)-1);                  

self.ctx.beginPath();                           

self.ctx.moveTo(Math.round(f.coordLast[coordRand].x), Math.round(f.coordLast[coordRand].y));

self.ctx.lineTo(Math.round(f.x), Math.round(f.y));

self.ctx.closePath();

self.ctx.strokeStyle = 'hsla('+f.hue+', 100%, '+f.brightness+'%, '+f.alpha+')';

self.ctx.stroke();  

if(self.showTarget){

    self.ctx.save();

    self.ctx.beginPath();

    self.ctx.arc(Math.round(f.targetX), Math.round(f.targetY), rand(1,8), 0, Math.PI*2, false)

    self.ctx.closePath();

    self.ctx.lineWidth = 1;

    self.ctx.stroke();

    self.ctx.restore();

}

    

if(self.showShockwave){

    self.ctx.save();

    self.ctx.translate(Math.round(f.x), Math.round(f.y));

    self.ctx.rotate(f.shockwaveAngle);

    self.ctx.beginPath();

    self.ctx.arc(0, 0, 1*(f.speed/5), 0, Math.PI, true);

    self.ctx.strokeStyle = 'hsla('+f.hue+', 100%, '+f.brightness+'%, '+rand(25, 60)/100+')';

    self.ctx.lineWidth = f.lineWidth;

    self.ctx.stroke();

    self.ctx.restore();

}

};

};

self.bindEvents = function(){

$(window).on('resize', function(){          

clearTimeout(self.timeout);

self.timeout = setTimeout(function() {

    self.canvas.width = self.cw = $(window).innerWidth();

    self.canvas.height = self.ch = $(window).innerHeight();

    self.ctx.lineCap = 'round';

    self.ctx.lineJoin = 'round';

}, 100);

});

$(self.canvas).on('mousedown', function(e){

self.mx = e.pageX - self.canvas.offsetLeft;

self.my = e.pageY - self.canvas.offsetTop;

self.currentHue = rand(self.hueMin, self.hueMax);

self.createFireworks(self.cw/2, self.ch, self.mx, self.my); 

$(self.canvas).on('mousemove.fireworks', function(e){

    self.mx = e.pageX - self.canvas.offsetLeft;

    self.my = e.pageY - self.canvas.offsetTop;

    self.currentHue = rand(self.hueMin, self.hueMax);

    self.createFireworks(self.cw/2, self.ch, self.mx, self.my);                                 

});             

});

$(self.canvas).on('mouseup', function(e){

$(self.canvas).off('mousemove.fireworks');                                  

});

        

}

self.clear = function(){

self.particles = [];

self.fireworks = [];

self.ctx.clearRect(0, 0, self.cw, self.ch);

};

self.canvasLoop = function(){

requestAnimFrame(self.canvasLoop, self.canvas);         

self.ctx.globalCompositeOperation = 'destination-out';

self.ctx.fillStyle = 'rgba(0,0,0,'+self.clearAlpha/100+')';

self.ctx.fillRect(0,0,self.cw,self.ch);

self.updateFireworks();

self.updateParticles();

self.drawFireworks();           

self.drawParticles();

};

self.init();        

}

var fworks = new Fireworks();

});

/script

script type="text/javascript"

$(document).ready(function() {

setTimeout(function() {

$("#header").hide("slow");

},2000);

});

/script

/body

/html

怎么把这个网页烟花代码的黑色背景去掉或换成红色的?

你把CSS中的这两行的background改下

body{overflow:hidden; background:red;}

html{overflow:hidden; background:red;}

关于烟花js代码和java烟花代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/7984.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载