【编程游戏】贺岁放礼花。(点燃续帖2-26楼lshdic的焰火)

本编程游戏通过JavaScript实现了一款贺岁的放礼花效果。游戏中包含多种烟花效果,如随机炸开、阿基米德螺旋式炸开等,同时还有独特的恭喜祝福语动画效果。游戏利用HTML和CSS进行页面布局。
<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=905" marginheight="0" marginwidth="0" scrolling="no" width="100%" frameborder="0" height="400"></iframe> <HTML><HEAD><META http-equiv='Content-Type' content='text/html;charset=utf8'> <TITLE>不眠夜</TITLE> <STYLE>font{position:absolute;z-index:2}div{position:absolute;z-index:5;}</STYLE> </HEAD><BODY bgcolor="black" text="white" style="overflow:hidden;"> <div id="a" style="width:100%;height:100%;background-color:black";></div> <script> var xall=screen.availWidth,yall=screen.availHeight-180,$=Math.random function gcor(){return ($()*4096).toString(16)} onload=function(){ //启动 var i=0;while(i++<8)setTimeout("p.add()",i*300) for(i=0;i++<30;)setTimeout("she.add()",i*120) setInterval("loadx=$()*xall;loadsize=10+($()*25);",5000) } var loadx=$()*xall,loadsize=10+($()*25) //副线程1:龙蛇 var she={ add:function(){ var d=document.createElement("font") d.color=gcor();d.dx=loadsize;d.dx2=5;d.max=5;with(d.style){fontSize=loadsize;left=loadx;top=yall;} d.innerText="·";d.go=setInterval(function(){she.go(d)},45);a.appendChild(d); }, go:function(obj){ var x=obj.offsetLeft,y=obj.offsetTop,dx=obj.dx,max=obj.max max%2==0?obj.dx2++:obj.dx2--;var dx2=obj.dx2 if(dx2==-max||dx2==max)obj.max++ obj.style.top=y-(dx/3);obj.style.left=x+(dx2*4) if(y<yall-(dx*20)){clearInterval(obj.go);a.removeChild(obj);she.add();} }} var p={ //1:不同上升蛋 add:function(){ var size1=6+($()*25),x=$()*xall var d=document.createElement("font"),ad=Math.ceil($()*5),t="●" d.color=gcor();with(d.style){fontSize=size1;left=x;top=yall;} if(ad==2){t="★"}else if(ad==3){t="*"}else if(ad==4){t="·"}else if(ad==5){t="◎"}; d.innerText=t;d.ad=ad;d.go=setInterval(function(){p.go(d,size1)},35);a.appendChild(d) }, go:function(obj,dx){ var y=obj.offsetTop;obj.style.top=y-(dx/7) if(y<yall-(dx*15))return p.bao(obj,y) }, bao:function(obj,y){ var x=obj.offsetLeft,ad=obj.ad,s=parseInt(obj.style.fontSize),c=obj.color clearInterval(obj.go); if(ad!=3){a.removeChild(obj);p.add()} if(ad==1){for(var i=0;i<($()*12)+8;i++){flash1.add(x,y,s,c)}} else if(ad==2){for(var i=0;i<($()*12)+12;i++){flash2.add(x,y,i+10,s)}} else if(ad==3){ obj.face="楷体_GB2312";obj.jia=0;obj.innerText="恭/n喜" obj.style.fontSize=s*3;obj.style.left=x-(s*2);obj.style.top=y-(s*2); clearInterval(obj.go);obj.go=setInterval(function(){p.flash3_go2(obj)},50); var i=0;while(i++<4){setTimeout(function(){flash3.add(x,s)},i*900)} }else if(ad==4){flash4.add(x,y,s,c)} else if(ad==5){flash5.begin(x,y,s);} }, flash3_go2:function(obj){ //2:恭喜牛年发财 var c=obj.color,r=c.substr(1,2),g=c.substr(3,2),b=c.substr(5,2),dx=8,jia=obj.jia r=Math.floor(("0x"+r).toString(10));g=Math.floor(("0x"+g).toString(10));b=Math.floor(("0x"+b).toString(10)); if(jia==0){r+=dx;g+=dx;b+=dx;obj.color="rgb("+r+","+g+","+b+")"} else if(jia==15){r-=dx;g-=dx;b-=dx;obj.color="rgb("+r+","+g+","+b+")"} else{obj.color=gcor();jia++;obj.jia=jia;if(obj.jia==15)obj.innerText="发/n财"} if(r>255||g>255||b>255){obj.jia=1;obj.innerText="牛/n年"} if(r+g+b<0){clearInterval(obj.go);a.removeChild(obj);p.add()} }} var flash1={ //3:随机炸 add:function(x,y,size1,color1){ var dx=Math.round($()*50)-25,dy=Math.round($()*50)-25 if(Math.abs(dx)<5)dx=10;if(Math.abs(dy)<5)dy=-10; var d=document.createElement("font"); with(d.style){fontSize=size1;left=x;top=y;}d.color=color1; d.innerText="●";d.go=setInterval(function(){flash1.go(d,x,y,dx,dy)},30);a.appendChild(d) }, go:function(obj,x,y,dx,dy){ var x2=obj.offsetLeft,y2=obj.offsetTop if(Math.abs(x-x2)<150&&Math.abs(y-y2)<150){obj.style.left=x2+dx;obj.style.top=y2+dy;}else{clearInterval(obj.go);a.removeChild(obj);} }} var cn=true,flash2={ //4:阿基米德炸 add:function(x,y,pos,size1){ var d=document.createElement("font"); with(d.style){fontSize=size1;left=x;top=y;} d.color=gcor();d.innerText="★"; d.go=setInterval(function(){flash2.go(d,x,y,pos,cn)},30);a.appendChild(d);cn=!cn }, go:function(obj,x,y,p,cn){ var x2=obj.offsetLeft,y2=obj.offsetTop if(Math.abs(x-x2)<125&&Math.abs(y-y2)<125){ if(cn){obj.style.left=x2+(p*Math.cos(p));obj.style.top=y2+(p*Math.sin(p))}else{obj.style.left=x2+(p*Math.sin(p));obj.style.top=y2+(p*Math.cos(p))} }else{clearInterval(obj.go);a.removeChild(obj);} }} var flash3={ //5:连环冲天 add:function(x,size1){ var arr=[],x2=$()*100-50+x,d=document.createElement("div"); with(d.style){left=x2;top=yall;} for(var i=0;i++<5;){var os=size1+2-(i*2);if(os<1)os=1;arr[i]="<font color='"+gcor()+"' style='font-size:"+os+"'>*</font><br>"} d.innerHTML=arr.join("");d.go=setInterval(function(){flash3.go(d)},30);a.appendChild(d); }, go:function(obj){ var top1=obj.offsetTop;obj.style.top=top1-30;if(top1<-50){clearInterval(obj.go);a.removeChild(obj)} }} var flash4={ //6:漫天星 add:function(x,y,size1,color1){ var arr=[],d=document.createElement("div");d.ci=1; with(d.style){left=x;top=y;fontSize=size1;color=color1;} for(var i=0;i++<($()*60)+40;){ var gx=size1*12,sx=$()*gx-(gx/2),sy=$()*gx-(gx/2); arr[i]="<font style='left:"+sx+";top:"+sy+"'>.</font>" } d.innerHTML=arr.join("");d.go=setInterval(function(){flash4.go(d)},70);a.appendChild(d); }, go:function(obj){ var ci=obj.ci++;if(ci==30){clearInterval(obj.go);return a.removeChild(obj)} ci%2==0?obj.style.visibility="visible":obj.style.visibility="hidden"; }} var mp=Math.PI,lr=true,flash5={ //7:圆形花 begin:function(x,y,s){ var pishu=Math.round($()*10)+8,zhou=Math.round($()*100)+60 lr=!lr;for(var i=0;i++<pishu;){var jiao=i*(360/pishu);flash5.add(x,y,s,jiao,zhou)} }, add:function(x,y,s,jiao,zhou){ var d=document.createElement("font") d.color=gcor();with(d.style){fontSize=s;left=x;top=y} d.innerText="◎";d.jiao=jiao;d.ci=0;d.lr=lr d.go=setInterval(function(){flash5.go(d,x+(zhou*Math.cos(jiao*mp/180)),y+(zhou*Math.sin(jiao*mp/180)),zhou)},50);a.appendChild(d); }, go:function(obj,x,y,zhou){ obj.lr?obj.jiao+=12:obj.jiao-=12;if(obj.ci++>30){clearInterval(obj.go);return a.removeChild(obj)} var jiao=obj.jiao obj.style.left=x+(zhou*Math.cos(jiao*mp/180));obj.style.top=y+(zhou*Math.sin(jiao*mp/180)) }} </script></BODY></HTML>
点燃[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值