【编程游戏】贺岁放礼花。(点燃续帖1-143楼KiteGirl的焰火)

本编程游戏通过JavaScript实现动态模拟烟花燃放效果。游戏中使用了多种算法来创建烟花的运动轨迹,并通过随机颜色增强视觉体验。每颗烟花的位置、规模及颜色各异,为观众带来丰富多彩的视觉盛宴。
<script type="text/javascript"> function viewPage(html) { var page = window.open('', '', ''); page.opener = null; page.document.write(html); page.document.close(); } </script> 【编程游戏】贺岁放礼花。(第一名奖励10000可用分)
作者: avatar
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行] <iframe src="http://vote.youkuaiyun.com/VotePostSimple.aspx?voteid=852" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="400"></iframe> <html> <head> <title></title> </head> <body bgcolor="#000000" text="#FFFFFF" style="overflow:hidden;"> <p id="idInsertObject"></p> </body> <script type="text/javascript"> function rgb(b, g, r) { return "#" + ("00" + Math.floor(r).toString(16)).replace(/^.*(/w{2}$)/g, "$1") + ("00" + Math.floor(g).toString(16)).replace(/^.*(/w{2}$)/g, "$1") + ("00" + Math.floor(b).toString(16)).replace(/^.*(/w{2}$)/g, "$1"); } function $(id){ return document.getElementById(id); } var pubCellNumber var pubOrbits_X = new Array(256 * 16); var pubOrbits_Y = new Array(256 * 16); var pubOffList = new Array(256); var pubLimit_X = []; var pubLimit_Y = []; var pubSpanObjects = new Array(32 * 16); var pubColors = new Array(256 * 16) var pubStepOn = 0; var pubWorkOn = 0; var pubX = 0; var pubY = 0; var pubScale = 0; var pubTime = 0; var pubCellLength = 0; var pubLightLength = 0; var pubSpeed = 0; var pubGLimit = 0; window.onload = function () { pubCellLength = 24; pubLightLength = 15; CreateObjects(pubCellLength, pubLightLength); CreateColors(); CreateLimits(); NewSkyrocket(); ShowSkyrocket(); } function NewSkyrocket() { pubX = Math.floor(Math.random() * 640); pubY = Math.floor(Math.random() * 480); pubScale = Math.random() * 1 + 1; pubStepOn = 10; for (var tIndex = 0; tIndex <= pubCellLength; tIndex++) { pubOffList[tIndex] = Math.floor(Math.random() * 20) + 44; } CellsClear(); CreateColors(); CreateLimits(); pubTime = setTimeout("ShowSkyrocket();", 10); } function ShowSkyrocket() { if (pubWorkOn < 64) { pubWorkOn++; if (pubSpeed > 3) pubSpeed = pubSpeed - 2; ViewObjects(pubCellLength, pubLightLength, pubScale, pubX, pubY); CellsMove(pubOrbits_X, pubOrbits_Y, pubLimit_X, pubLimit_Y, pubCellLength, pubLightLength, pubSpeed); pubTime = setTimeout("ShowSkyrocket();", 1); } else { pubWorkOn = 0; pubSpeed = 24; NewSkyrocket(); } } function ViewObjects(pCellLength, pLightLength, pScale, pX, pY) { for (var tIndex = 0; tIndex <= pCellLength; tIndex++) { for (var tLight = 0; tLight <= pLightLength; tLight++) { with (pubSpanObjects[tIndex * 256 + tLight].style) { if (pubWorkOn > pubOffList[tIndex] + (pLightLength - tLight)) { color = rgb(0, 0, 0); } else { color = pubColors[tIndex * 256 + 15]; tRndBase = (pLightLength - tLight) * pubScale; top = pubOrbits_Y[tIndex * 256 + tLight] * pubScale + pY + Math.floor(Math.random() * tRndBase) - tRndBase / 2; tRndBase = (pLightLength - tLight) * pubScale; left = pubOrbits_X[tIndex * 256 + tLight] * pubScale + pX + Math.floor(Math.random() * tRndBase) - tRndBase / 2; } } } } } function CreateObjects(pCellLength, pLightLength) { for (var tIndex = 0; tIndex <= pCellLength; tIndex++) { for (var tLight = 0; tLight <= pLightLength; tLight++) { pubSpanObjects[tIndex * 256 + tLight] = document.createElement("SPAN"); with (pubSpanObjects[tIndex * 256 + tLight]) { innerHTML = "."; } with (pubSpanObjects[tIndex * 256 + tLight].style) { position = "absolute" color = rgb(0, 0, 0) } idInsertObject.appendChild(pubSpanObjects[tIndex * 256 + tLight]); } } } function CreateColors() { var tColor = new Array(3); tColor[0] = Math.random() * 0.5 + 0.5 ; tColor[1] = Math.random() * 0.5 + 0.5 ; tColor[2] = Math.random() * 0.5 + 0.5 ; tColor[Math.floor(Math.random() * 3)] = 1; for (var tColorIndex = 0; tColorIndex
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值