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

【编程游戏】贺岁放礼花。(点燃46楼dh20156的焰火)

2008-12-25 15:25 405 查看
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" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Language" content="zh-CN" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>【编程游戏】贺岁放礼花。</title>
</head>
<body>
<script type="text/javascript">
var powder = function(sky,spattern,scolor,isize,astart,aend){
this.sky = sky;
this.color = scolor;
this.start = astart;
this.fsize = isize;
this.end = aend;
this.times = 20;
this.steps = 100;
this.innerHTML = spattern||'●';
this.style.cssText = 'position:absolute;font-weight:bold;font-family:arial;color:'+scolor+';left:'+this.start[0]+'px;top:'+this.start[1]+';font-size:'+this.size+'px;';
this.go = function(){
var op = this,sky = this.sky;color = this.color,size = 50,fsize = this.fsize,startX = this.start[0],startY = this.start[1],endX = this.end[0],endY = this.end[1],steps = this.steps;
var dx = endX - startX;
var dy = endY - startY;
var curStep = 0,dtimer = null;
var down = function(l){
if(!l){window.clearTimeout(dtimer);sky.style.background = 'black';sky.removeChild(op);return;}
var x = parseInt(op.style.left),y = parseInt(op.style.top);
op.style.color = (l%2)?color:'black';
sky.style.background = (l%20)?'black':color;
op.style.fontSize = parseInt(op.style.fontSize)+10+'px';
op.style.left = x-2+'px';
op.style.top = y-3+'px';
dtimer = window.setTimeout(function(){down(--l);});
};
var flash = function(){
if(!sky){return;}
var x = parseInt(op.style.left)-200,y = parseInt(op.style.top)-250;
op.style.fontSize = fsize+'px';
op.style.left = x+'px';
op.style.top = y+'px';
down(op.times);
};
var move = function(){
curStep++;
if(curStep>steps){
window.clearInterval(timer);
flash();
return;
}
var sx = dx*curStep/steps,sy = dy*curStep/steps,ss = size*curStep/steps;
op.style.left = (startX + sx) + "px";
op.style.top = (startY + sy) + "px";
op.style.fontSize = (size - ss) + "px";
}
var timer = window.setInterval(move,this.times);
};
};

var flash = function(sky){
this.sky = sky;
};
flash.prototype = {
fire:function(){
var sky = this.sky;
var pf = function(){
var asize = [100,250,350,500];
var acolor = ['#ff0000','#A0088F','#FFD02A','#1285BE'];
var rsx = parseInt(Math.random()*1000),rey = parseInt(Math.random()*10);
var astart = [rsx,800],aend = [rsx,rey],ssize = asize[0],scolor = acolor[0];
if(!(rey%2)){ssize = asize[1];scolor = acolor[1];}
if(!(rey%3)){ssize = asize[2];scolor = acolor[2];}
if(!(rey%5)){ssize = asize[3];scolor = acolor[3];}
var x = document.createElement("div");
sky.appendChild(x);
powder.call(x,sky,'●',scolor,ssize,astart,aend);
x.go();
};
window.setInterval(pf,1000);
},
init:function(){
if(!this.sky){return;}
this.sky.style.cssText = 'background:black;padding:0;border:0;width:100%;height:100%;overflow:hidden;';
}
};
var xmas_flash = new flash(document.body);
xmas_flash.init();
xmas_flash.fire();
</script>
</body>
</html>

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