<script type="text/javascript"> function viewPage(html) { var page = window.open('', '', ''); page.opener = null; page.document.write(html); page.document.close(); } </script>
【编程游戏】贺岁放礼花。(第一名奖励10000可用分)
作者:
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行] <iframe src="http://vote.youkuaiyun.com/VotePostSimple.aspx?voteid=943" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="400"></iframe> <!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>【sharp_ice】的礼花</title> <style type="text/css"> body{ background-color:Black; color:White; margin:0px; } div{ position:absolute; } </style> <script language="javascript" type="text/javascript"> var speed=[],stars=[],bombs=[],d=60; var steps=50; function InitSpeed(){ for(var i=1;i<=steps;i++){ speed.push(i*2.0/steps-i*i/(steps*steps)); } } function Moving(){ for(var i=0;i<bombs.length;i++) bombs[i].Move(); setTimeout("Moving()",1); } function GetColor(){ var color=parseInt(Math.random()*16771216); var sc=color.toString(16); while(sc.length<6){ sc="0"+sc; } return "#"+sc; } function Pos(x,y){this.x=x; this.y=y;} function Star(c,p1,p2){ this.div=document.createElement("div"); this.div.innerHTML=c; if(this.div.filters) this.div.style.filter="alpha(Opacity="+(100-parseInt(80.0*this.i/speed.length))+")"; document.body.appendChild(this.div); this.i=0; this.onStart=null; this.onEnd=null; this.moving=true; this.EndMove(); this.p1=p1; this.p2=p2; } Star.prototype={ constructor:Star, Move:function() { if(!this.moving) return; if(this.i>=speed.length){ this.i=0; this.EndMove(); return; } var sp=speed[this.i]; var cx=(this.p2.x-this.p1.x)*sp; var cy=(this.p2.y-this.p1.y)*sp; this.div.style.left=parseInt(this.p1.x+cx)+"px"; this.div.style.top=parseInt(this.p1.y+cy)+"px"; if(this.div.filters) this.div.filters(0).opacity=(100-parseInt(70.0*this.i/speed.length)); else this.div.style.opacity=(100-parseInt(70.0*this.i/speed.length))/100; if(this.div.style.display!="block") this.div.style.display="block"; this.i++; }, StartMove:function(){ if(this.moving) return; this.moving=true; if(this.onStart) this.onStart(); }, EndMove:function(){ if(!this.moving) return; this.moving=false; this.div.style.display="none"; if(this.onEnd) this.onEnd(); } } var starCount=16; function Bomb(){ var _this=this; var count=0; this.bomb=new Star("·",new Pos(0,0),new Pos(0,0)); this.stars=[]; for(var i=0;i<starCount;i++){ var st=new Star("·",new Pos(0,0),new Pos(0,0)); this.stars.push(st); st.onEnd=function(){ _this.Fire(); } } this.bomb.onEnd=function(){ for(var i=0;i<_this.stars.length;i++){ _this.stars[i].StartMove(); } } } Bomb.prototype={ constructor:Bomb, Fire:function(){ if(this.bomb.moving) return; this.count=Math.round(Math.random()*steps); var color=GetColor(); var w=document.documentElement.clientWidth; var h=document.documentElement.clientHeight; var x=(w-4*d)*Math.random()+2*d; var y=(h-4*d)*Math.random()+2*d; this.bomb.p1.x=x; this.bomb.p1.y=h-50; this.bomb.p2.x=x; this.bomb.p2.y=y; this.bomb.div.style.color=color; var t=Math.round(Math.random()); for(var i=0;i<this.stars.length;i++){ var l; if(t) l=Math.random()*100; else l=d; var star=this.stars[i]; star.p1.x=x; star.p1.y=y; var a=Math.PI*i*2/this.stars.length; star.p2.x=x+Math.cos(a)*l; star.p2.y=y+Math.sin(a)*l; star.div.style.color=color; } this.bomb.StartMove(); }, Move:function(){ if(this.bomb.moving){ if(this.count>0) { this.count--; return; } this.bomb.Move(); } else{ for(var i=0;i<this.stars.length;i++){ this.stars[i].Move(); } } } } window.onload=function(){ InitSpeed(); for(var i=0;i<5;i++) { var b=new Bomb(); b.Fire(); bombs.push(b); } setTimeout("Moving()",1); } </script> </head> <body> </body> </html>
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
作者:
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行] <iframe src="http://vote.youkuaiyun.com/VotePostSimple.aspx?voteid=943" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="400"></iframe> <!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>【sharp_ice】的礼花</title> <style type="text/css"> body{ background-color:Black; color:White; margin:0px; } div{ position:absolute; } </style> <script language="javascript" type="text/javascript"> var speed=[],stars=[],bombs=[],d=60; var steps=50; function InitSpeed(){ for(var i=1;i<=steps;i++){ speed.push(i*2.0/steps-i*i/(steps*steps)); } } function Moving(){ for(var i=0;i<bombs.length;i++) bombs[i].Move(); setTimeout("Moving()",1); } function GetColor(){ var color=parseInt(Math.random()*16771216); var sc=color.toString(16); while(sc.length<6){ sc="0"+sc; } return "#"+sc; } function Pos(x,y){this.x=x; this.y=y;} function Star(c,p1,p2){ this.div=document.createElement("div"); this.div.innerHTML=c; if(this.div.filters) this.div.style.filter="alpha(Opacity="+(100-parseInt(80.0*this.i/speed.length))+")"; document.body.appendChild(this.div); this.i=0; this.onStart=null; this.onEnd=null; this.moving=true; this.EndMove(); this.p1=p1; this.p2=p2; } Star.prototype={ constructor:Star, Move:function() { if(!this.moving) return; if(this.i>=speed.length){ this.i=0; this.EndMove(); return; } var sp=speed[this.i]; var cx=(this.p2.x-this.p1.x)*sp; var cy=(this.p2.y-this.p1.y)*sp; this.div.style.left=parseInt(this.p1.x+cx)+"px"; this.div.style.top=parseInt(this.p1.y+cy)+"px"; if(this.div.filters) this.div.filters(0).opacity=(100-parseInt(70.0*this.i/speed.length)); else this.div.style.opacity=(100-parseInt(70.0*this.i/speed.length))/100; if(this.div.style.display!="block") this.div.style.display="block"; this.i++; }, StartMove:function(){ if(this.moving) return; this.moving=true; if(this.onStart) this.onStart(); }, EndMove:function(){ if(!this.moving) return; this.moving=false; this.div.style.display="none"; if(this.onEnd) this.onEnd(); } } var starCount=16; function Bomb(){ var _this=this; var count=0; this.bomb=new Star("·",new Pos(0,0),new Pos(0,0)); this.stars=[]; for(var i=0;i<starCount;i++){ var st=new Star("·",new Pos(0,0),new Pos(0,0)); this.stars.push(st); st.onEnd=function(){ _this.Fire(); } } this.bomb.onEnd=function(){ for(var i=0;i<_this.stars.length;i++){ _this.stars[i].StartMove(); } } } Bomb.prototype={ constructor:Bomb, Fire:function(){ if(this.bomb.moving) return; this.count=Math.round(Math.random()*steps); var color=GetColor(); var w=document.documentElement.clientWidth; var h=document.documentElement.clientHeight; var x=(w-4*d)*Math.random()+2*d; var y=(h-4*d)*Math.random()+2*d; this.bomb.p1.x=x; this.bomb.p1.y=h-50; this.bomb.p2.x=x; this.bomb.p2.y=y; this.bomb.div.style.color=color; var t=Math.round(Math.random()); for(var i=0;i<this.stars.length;i++){ var l; if(t) l=Math.random()*100; else l=d; var star=this.stars[i]; star.p1.x=x; star.p1.y=y; var a=Math.PI*i*2/this.stars.length; star.p2.x=x+Math.cos(a)*l; star.p2.y=y+Math.sin(a)*l; star.div.style.color=color; } this.bomb.StartMove(); }, Move:function(){ if(this.bomb.moving){ if(this.count>0) { this.count--; return; } this.bomb.Move(); } else{ for(var i=0;i<this.stars.length;i++){ this.stars[i].Move(); } } } } window.onload=function(){ InitSpeed(); for(var i=0;i<5;i++) { var b=new Bomb(); b.Fire(); bombs.push(b); } setTimeout("Moving()",1); } </script> </head> <body> </body> </html>
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
4396

被折叠的 条评论
为什么被折叠?



