您的位置:首页 > 编程语言

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

2008-12-30 12:08 633 查看
function viewPage(html) {
var page = window.open('', '', '');
page.opener = null;
page.document.write(html);
page.document.close();
}

【编程游戏】贺岁放礼花。(第一名奖励10000可用分)
作者:


点燃 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<style type="text/css">
body {
background: #000;
font-size: 4pt;
}
</style>
<script type="text/javascript">
var Scene = function()
{
this.Left = 200;
this.Right = document.documentElement.clientWidth - 200;
this.Width = document.documentElement.clientWidth - 400;
this.Top = 200;
this.Bottom = document.documentElement.clientHeight - 10;
this.Height = document.documentElement.clientHeight - 210;
}
Scene.Cache = [];
Scene.prototype.Play = function()
{
if (document.body.childNodes.length - Scene.Cache.length > 60) return;

var symbol = ["☆", "★", "○", "●", "◎", "◇", "◆", "□", "■", "※"];
var x = parseInt(Math.random() * this.Width) + this.Left;
var y = this.Bottom;
var n = parseInt(Math.random() * 30) + 50; // 散开数量
var top = this.Top + parseInt(Math.random() * 150);

var s = Scene.Cache.shift();
if (!s)
{
s = document.createElement("span");
s.innerHTML = symbol[parseInt(Math.random() * symbol.length)];
s.style.position = "absolute";
document.body.appendChild(s);
}
s.style.color = "rgb(256,256,256)";
s.style.left = x + "px";
s.style.top = y + "px";
(function()
{
y -= 20;
if (y > top)
{
s.style.top = y + "px";
setTimeout(arguments.callee, 1);
}
else
{

for (var i = 0; i < n; i++)
{
(function()
{
var x2 = x;
var y2 = y - 20;
var s2 = Scene.Cache.shift();
if (!s2)
{
s2 = document.createElement("span");
s2.innerHTML = symbol[parseInt(Math.random() * symbol.length)];
s2.style.position = "absolute";
document.body.appendChild(s2);
}
var r2 = 256;
var g2 = 256;
var b2 = 256;
var top2 = y2 - parseInt(Math.random() * 100);
var horizon2 = x2 + parseInt(Math.random() * 200) - 100;
var count = parseInt(Math.random() * 30) + 20;
var hStep = (horizon2 - x2) / count;
var vStep = (top2 - y2) / count;
var n = 0;

setTimeout(function()
{
if (n < count)
{
x2 += hStep;
y2 += vStep;
r2 -= parseInt(Math.random() * 8);
g2 -= parseInt(Math.random() * 8);
b2 -= parseInt(Math.random() * 8);

s2.style.color = "rgb(" + r2 + "," + g2 + "," + b2 + ")";
s2.style.left = x2 + "px";
s2.style.top = y2 + "px";
n++;
setTimeout(arguments.callee, 1);
}
else
{
top2 = y2 + parseInt(Math.random() * 100) + 250;
vStep = (top2 - y2) / count;
n = 0;
setTimeout(function()
{
if (n < count)
{
x2 += hStep;
y2 += vStep;
r2 -= parseInt(Math.random() * 4);
g2 -= parseInt(Math.random() * 4);
b2 -= parseInt(Math.random() * 4);

s2.style.color = "rgb(" + r2 + "," + g2 + "," + b2 + ")";
s2.style.left = x2 + "px";
s2.style.top = y2 + "px";
n++;
setTimeout(arguments.callee, 1);
}
else
{
s2.style.color = "rgb(0,0,0)";
Scene.Cache.push(s2);
}
}, 0);
}
}, 0);
})();
}
s.style.color = "rgb(0,0,0)";
Scene.Cache.push(s);
}
})();
}

window.onload = function()
{
var scene = new Scene();
(function()
{
scene.Play();
setTimeout(arguments.callee, Math.random() * 1000 + 500);
})();
}
</script>
</head>
<body style="">
</body>
</html>

点燃 [Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐