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

【编程游戏】贺岁放礼花。(第一名奖励10000可用分)
作者: 【编程游戏】贺岁放礼花。(点燃17楼dh20156的焰火)_第1张图片
点燃  [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,astart,aend){ this.sky = sky; this.size = 50; this.color = scolor; this.start = astart; 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 = this.size,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; var flash = function(){ if(!sky){return;} var sbg = sky.style.background = color; window.setTimeout(function(){sky.style.background = 'black';sky.removeChild(op);}); }; 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 rsx = parseInt(Math.random()*1000),rey = parseInt(Math.random()*10); var astart = [rsx,800],aend = [rsx,rey]; var x = document.createElement("div"); sky.appendChild(x); powder.call(x,sky,'●','red',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>

你可能感兴趣的:(html,游戏,编程,timer,function,Flash)