- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <HTML><HEAD>
- <TITLE>俄罗斯方块</TITLE>
- <META http-equiv=Content-Type content="text/html; charset=gb2312">
- <META content="MSHTML 6.00.2900.3059" name=GENERATOR>
- <META content="乐不思学" name=Author>
- <META content="" name=Keywords>
- <META content="" name=Description></HEAD>
- <style>
- td ...{width: 20px;height:20px;}
- #box...{width:510px;1px solid #fff;}
- #main...{float:left;width:340px;}
- #left...{float:right;width:150px;padding:5px;}
- #left1...{width:150px;border:1px solid #fff;padding:5px;color:#66CC99;}
- #left2...{width:150px;color:#0066FF;padding:5px;}
- #count_score...{color:yellow;}
- #buttonkey...{margin-left:4px;}
- </style>
- <BODY οnkeydοwn="control()" οnkeypress="addspeed()" rightMargin=50 leftMargin=200 topMargin=8>
- <p>
- <SCRIPT language=JavaScript src="http://www.uptoday.cn/fun/playrecord.js"></SCRIPT>
- <SCRIPT language=JavaScript>
- /**//*********************************************************************
- 作者:乐不思学 gsx123@gmail.com QQ:254539697
- 主页:http://www.uptoday.cn
- 日期:2007-10-31 完成
- 功能:纯JAVASCRIPT代码游戏 - 俄罗斯方块
- ************************************************************************/
- /**//* 常量 */
- var TDX=18;//竖行格数
- var TDY=12;//横行格数
- var speed=300; //下降速度
- var highspeed=90; //快速下降速度
- var body_back_COLOR="#000"; //页面背景颜色
- var back_COLOR="#000";//背景颜色
- var next_back_COLOR=""; //预告框背景色
- var side_COLOR="#996600"; //围栏颜色
- var msgGameOver="GAME OVER !";
- var msg_start=" 开 始 ";
- var msg_stop=" 暂 停 ";
- var boom_num=3; //炸弹数
- var mod=0; //难度增加模式
- var q; //时钟
- var linesup_speed=15000;
- var intlinesup=1;
- var timer="1";
- var level=new Array(1000,2000,3000,4000,5000); //升级分数
- document.write("<style>td {background-color: "+back_COLOR+";}body{background-color:"+body_back_COLOR+" ;}</style>");
- //********************//
- /**//* 全局变量*/
- var now_obj; //当前物体
- var next_obj; //下一物体
- var isStart=false; //是否开始了游戏
- var isEnd=false; //是否游戏结束
- var count_line=0; //消除的行数
- var count_score=0; //记分
- var glo_statu=new Array(); //背景单元格状态 false为空
- var obj_member=new Array(); //物体成员
- var d=document.getElementById;
- for(i=0;i<13;i++)
- ...{
- obj_member[i]=new Array();
- }
- for(i=-4;i<=TDX;i++) //初始化背景单元格状态
- ...{ glo_statu[i]=new Array();
- for(j=0;j<=TDY;j++)
- ...{
- if(j==0||j==TDY||i==TDX)
- glo_statu[i][j]=true;
- else ...{glo_statu[i][j]=false;}
- }
- }
- //**********************************************************************************//
- /**//* 定义对象*/
- function obje(color,length,style,type,x0,y0,getxy)
- ...{
- this.color=color; //颜色
- this.length=length; //单元格数
- this.style=style; //样式
- this.type=type; //4形态
- var x=new Array(); //每格x坐标
- var y=new Array(); //每格y坐标
- x[0]=x0; //首格
- y[0]=y0;
- this.x=x;
- this.y=y;
- this.getxy=getxy; //另三格坐标相对首格的偏移量
- this.build=buildfunction; //计算另三格坐标
- }
- function buildfunction() //由偏移量构造另三格坐标
- ...{
- with(this)
- ...{
- x[1]=x[0]+getxy[0];
- y[1]=y[0]+getxy[1];
- x[2]=x[0]+getxy[2];
- y[2]=y[0]+getxy[3];
- x[3]=x[0]+getxy[4];
- y[3]=y[0]+getxy[5];
- }
- }
- var objNum=0;
- //
- // [1][2] [2][0][3] [3]
- // [0] [1] [0] [1]
- // [3] [2][1] [3][0][2]
- //
- var tt=new Array();var color="red"; var len=4;var sty=0;var x0=-2;var y0=5;
- tt[0]=new Array(-1,-1,-1,0,1,0);
- tt[1]=new Array(1,-1,0,-1,0,1)
- tt[2]=new Array(1,1,1,0,-1,0);
- tt[3]=new Array(-1,1,0,1,0,-1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [2][1] [1] [3]
- // [0] [2][0][3] [0] [3][0][2]
- // [3] [1][2] [1]
- //
- color="#CC6666";sty++;
- tt[0]=new Array(-1,1,-1,0,1,0);
- tt[1]=new Array(-1,-1,0,-1,0,1)
- tt[2]=new Array(1,-1,1,0,-1,0);
- tt[3]=new Array(1,1,0,1,0,-1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [2] [3] [1]
- // [1][0][3] [2][0] [3][0][1] [0][2]
- // [1] [2] [3]
- //
- color="blue";sty++;
- tt[0]=new Array(0,-1,-1,0,0,1);
- tt[1]=new Array(1,0,0,-1,-1,0)
- tt[2]=new Array(0,1,1,0,0,-1);
- tt[3]=new Array(-1,0,0,1,1,0);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- // [3] [3]
- // [0] [0]
- // [1][2][0][3] [2] [1][2][0][3] [2]
- // [1] [1]
- //
- color="green";sty++;
- tt[0]=new Array(0,-2,0,-1,0,1);
- tt[1]=new Array(2,0,1,0,-1,0);
- tt[2]=new Array(0,-2,0,-1,0,1);
- tt[3]=new Array(2,0,1,0,-1,0);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1] [2][3] [1] [2][3]
- // [0][2] [1][0] [0][2] [1][0]
- // [3] [3]
- //
- color="#660099";sty++;
- tt[0]=new Array(-1,0,0,1,1,1);
- tt[1]=new Array(0,-1,-1,0,-1,1);
- tt[2]=new Array(-1,0,0,1,1,1);
- tt[3]=new Array(0,-1,-1,0,-1,1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- //
- // [0][1]
- // [2][3]
- //
- color="yellow";sty++;
- tt[0]=new Array(0,1,1,0,1,1);
- tt[1]=new Array(0,1,1,0,1,1);
- tt[2]=new Array(0,1,1,0,1,1);
- tt[3]=new Array(0,1,1,0,1,1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1] [1] [1][0]
- // [2][0] [1][0] [2][0] [2][3]
- // [3] [2][3] [3]
- //
- color="#999966";sty++;
- tt[0]=new Array(-1,0,0,-1,1,-1);
- tt[1]=new Array(0,-1,1,0,1,1);
- tt[2]=new Array(-1,0,0,-1,1,-1);
- tt[3]=new Array(0,-1,1,0,1,1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++; //7
- //
- // [2][3]
- // [0] [2]
- // [1] [3] [0][1]
- //
- color="#66FF66";sty++;
- tt[0]=new Array(1,0,0,2,1,2);
- tt[1]=new Array(0,1,-2,0,-2,1);
- tt[2]=new Array(1,0,0,2,1,2);
- tt[3]=new Array(0,1,-2,0,-2,1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1] [2][3]
- // [0] [2]
- // [3] [1][0]
- //
- color="#66FF66";sty++;
- tt[0]=new Array(-1,0,0,2,1,2);
- tt[1]=new Array(0,-1,-2,0,-2,1);
- tt[2]=new Array(-1,0,0,2,1,2);
- tt[3]=new Array(0,-1,-2,0,-2,1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1] [3] [3] [2] [2]
- // [0] [1][0] [0] [0][1]
- // [2] [3] [2] [1] [3]
- //
- color="#66FF66";sty++;
- tt[0]=new Array(-1,0,1,-1,1,1);
- tt[1]=new Array(0,-1,1,1,-1,1);
- tt[2]=new Array(1,0,-1,-1,-1,1);
- tt[3]=new Array(0,1,-1,-1,1,-1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1][0][2] [2] [3] [1]
- // [0] [3] [3] [0]
- // [3] [1] [2][0][1] [2]
- //
- color="#66FF66";sty++;
- tt[0]=new Array(0,-1,0,1,2,0);
- tt[1]=new Array(1,0,-1,0,0,2);
- tt[2]=new Array(0,-1,0,1,-2,0);
- tt[3]=new Array(1,0,-1,0,0,-2);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1]
- // [2] [0]
- // [3]
- //
- color="#66FF66";sty++;
- tt[0]=new Array(-1,-1,0,-2,1,-1);
- tt[1]=new Array(-1,-1,0,-2,1,-1);
- tt[2]=new Array(-1,-1,0,-2,1,-1);
- tt[3]=new Array(-1,-1,0,-2,1,-1);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- //
- // [1] [0]
- //
- // [3] [2]
- //
- color="#33CCCC";sty++;
- tt[0]=new Array(0,-2,2,0,2,-2);
- tt[1]=new Array(0,-2,2,0,2,-2);
- tt[2]=new Array(0,-2,2,0,2,-2);
- tt[3]=new Array(0,-2,2,0,2,-2);
- for(i=0;i<4;i++)
- ...{
- obj_member[sty][i]=new obje(color,len,sty,i,x0,y0,tt[i]);
- obj_member[sty][i].build();
- }
- objNum++;
- var temp1=Math.floor(Math.random()*(7));
- var temp2=Math.floor(Math.random()*(3));
- now_obj=obj_member[temp1][temp2]; //初始化当前物体!!
- var boom_added=false;
- function getNextObj() //{{生成下一物体}}
- ...{
- if(count_score>=level[4]) //难度控制
- ...{ if(mod=="0")...{speed=90;}
- else if(mod=="2")
- ...{
- if(timer!="1"&&intlinesup==5)
- ...{clearInterval(timer);timer=setInterval("linesup()",5000);intlinesup=6;}
- }
- else thenum=objNum;
- document.getElementById("level").innerHTML=6;
- if(boom_added)...{boom_added=false;boom_num++;pic="";
- for(k=1;k<=boom_num;k++)
- pic+=" ※";
- document.getElementById("boom").innerHTML=pic;
- }
- }
- else if(count_score>=level[3]&&count_score<level[4]) //难度控制
- ...{ if(mod=="0")...{speed=110;}
- else if(mod=="2")
- ...{
- if(timer!="1"&&intlinesup==4)
- ...{clearInterval(timer);timer=setInterval("linesup()",6500);intlinesup=5;}
- }
- else thenum=objNum-1;
- document.getElementById("level").innerHTML=5;
- if(!boom_added)...{boom_added=true;boom_num++;pic="";
- for(k=1;k<=boom_num;k++)
- pic+=" ※";
- document.getElementById("boom").innerHTML=pic;
- }
- }
- else if(count_score>=level[2]&&count_score<level[3])
- ...{ if(mod=="0")...{speed=150;}
- else if(mod=="2")
- ...{if(timer!="1"&&intlinesup==3)...{clearInterval(timer);timer=setInterval("linesup()",9000);intlinesup=4;}}
- else thenum=(objNum-2);
- document.getElementById("level").innerHTML=4;}
- else if(count_score>=level[1]&&count_score<level[2])
- ...{ if(mod=="0")...{speed=180;}
- else if(mod=="2")
- ...{if(timer!="1"&&intlinesup==2)...{clearInterval(timer);timer=setInterval("linesup()",12000);intlinesup=3;}}
- else thenum=(objNum-3);
- document.getElementById("level").innerHTML=3;}
- else if(count_score>=level[0]&&count_score<level[1])
- ...{ if(mod=="0")...{speed=220;}
- else if(mod=="2")
- ...{if(timer=="1")...{timer=setInterval("linesup()",15000);intlinesup=2;}}
- else thenum=(objNum-4);
- document.getElementById("level").innerHTML=2;}
- else
- ...{
- thenum=7;}
- var temp1=Math.floor(Math.random()*(thenum));
- var temp2=Math.floor(Math.random()*(3));
- next_obj=obj_member[temp1][temp2];
- }
- getNextObj(); //初始化下一物体!!
- //**********************************************************************************//
- /**//* 函数 /
- /*-------------------------*/
- function control() // 键盘控制
- ...{
- var key=event.keyCode;
- switch(key)
- ...{
- case 37:moveleft(now_obj); break; // ←
- case 39:moveright(now_obj); break; // →
- case 40: // ↓
- // if(!isStart)
- // autodown(now_obj);
- //else
- // {
- stop();
- q=setInterval("movedown(now_obj)",highspeed);
- // }
- break;
- case 38:turn(now_obj); break; // ↑
- case 32:boom(); break; // ↑
- }
- }
- function addspeed() //加速
- ...{
- if(event.keyCode==40&&isStart)
- ...{
- speed=highspeed;
- }
- }
- function highspeed() //
- ...{
- if(!q)...{autodown();}
- else...{
- stop();
- q=setInterval("movedown(now_obj)",highspeed);
- }
- }
- function show(obj) //显示物体
- ...{
- for(i=0;i<obj.length;i++)
- ...{if(obj.x[i]>=0)
- ...{
- document.getElementById("d_"+obj.x[i]+"_"+obj.y[i]).style.background=obj.color;
- }
- glo_statu[obj.x[i]][obj.y[i]]=true;
- }
- }
- function hid(obj) //消失物体
- ...{
- for(i=0;i<obj.length;i++)
- ...{
- if(obj.x[i]>=0)
- ...{
- document.getElementById("d_"+obj.x[i]+"_"+obj.y[i]).style.background=back_COLOR;
- }
- glo_statu[obj.x[i]][obj.y[i]]=false;
- }
- }
- function array_walk(arr,flag)//处理数组中每一项
- ...{
- for(i=0;i<arr.length;i++)
- ...{
- switch(flag)
- ...{
- case "+":arr[i]++; break;
- case "-":arr[i]--; break;
- case "false": glo_statu[arr.x[i]][arr.y[i]]=false;break;
- case "true" : glo_statu[arr.x[i]][arr.y[i]]=true; break;
- }
- }
- }
- function canmove(obj,to) //能否继续移动 ??
- ...{
- var can=true;
- array_walk(obj,"false");
- switch(to)
- ...{
- case "down": array_walk(obj.x,"+");break;
- case "left": array_walk(obj.y,"-");break;
- case "right":array_walk(obj.y,"+");break;
- }
- for(i=0;i<obj.x.length;i++)
- ...{
- if(glo_statu[obj.x[i]][obj.y[i]]==true)
- ...{
- can=false;
- break;
- }
- }
- switch(to)
- ...{
- case "down": array_walk(obj.x,"-");break;
- case "left": array_walk(obj.y,"+");break;
- case "right":array_walk(obj.y,"-");break;
- }
- array_walk(obj,"true");
- return can;
- }
- function autodown() //开始自动下移 start
- ...{
- if(!isEnd)
- ...{
- q=setInterval("movedown(now_obj)",speed);
- if(!isStart)isStart=true;
- }
- document.getElementById("butt").value=msg_stop;
- }
- function stop() ...{clearInterval(q);} //停止 stop
- function movedown(obj) //下移 ↓↓
- ...{
- if(canmove(obj,"down"))
- ...{
- hid(obj);
- for(i=0;i<obj.length;i++)
- ...{
- obj.x[i]++;
- }
- show(obj);
- }
- else //触底
- ...{
- stop();
- check_clearline(obj);
- for(y=0;y<obj.length;y++) //判断游戏结束
- ...{
- if(obj.x[y]<2)...{isEnd=true;}
- else...{isEnd=false;}
- }
- if(isEnd)
- ...{
- window.alert(msgGameOver);
- document.getElementById("butt").value="重来";
- }
- else...{
- now_obj=next_obj;
- now_obj.x[0]=x0;now_obj.y[0]=y0;now_obj.build();
- fornext(next_obj,"hidden");
- getNextObj();
- fornext(next_obj,"show");
- //show(now_obj);
- //window.alert(now_obj.x);
- autodown();
- }
- }
- }
- function check_clearline(obj) //是否有满行,清除行
- ...{
- var clearnum=0;
- var c=0;
- var max=obj.x[0];var min=obj.x[0];
- for(i=1;i<obj.length;i++)
- ...{
- if(obj.x[i]>max)max=obj.x[i];
- else if(obj.x[i]<min)min=obj.x[i];
- }
- for(i=max;i>=min;i--)
- ...{
- var isfull=true;
- for(j=1;j<TDY;j++)
- ...{
- if(glo_statu[i][j]==false)isfull=false;
- }
- if(isfull)
- ...{
- clearline(i);
- clearnum++;
- lines_down(i);
- i=max+1;
- //if(mod=="2")linesup();
- }
- }
- count_score=parseInt(document.getElementById("count_score").innerHTML);
- switch(clearnum) //加分
- ...{
- case 0: break;
- case 1: count_score+=100;break;
- case 2: count_score+=300;break;
- case 3: count_score+=500;break;
- case 4: count_score+=800;break;
- }
- document.getElementById("count_score").innerHTML=count_score;
- }
- function clearline(i) //清除行
- ...{
- for(j=1;j<TDY;j++)
- ...{
- document.getElementById("d_"+i+"_"+j).style.background=back_COLOR;
- glo_statu[i][j]=false;
- //document.getElementById("d_"+i+"_"+j).innerHTML=glo_statu[i][j];
- }
- line=parseInt(document.getElementById("count_line").innerHTML);
- line+=1;
- document.getElementById("count_line").innerHTML=line;
- }
- function lines_down(lineKilled) //清除行后下移其上方块
- ...{
- for(i=lineKilled-1;i>0;i--)
- ...{
- for(j=1;j<TDY;j++)
- ...{
- if(glo_statu[i][j])
- ...{
- temp=i;
- var tempcolor=document.getElementById("d_"+i+"_"+j).style.background;
- document.getElementById("d_"+i+"_"+j).style.background=back_COLOR;
- glo_statu[temp][j]=false;
- temp++;
- glo_statu[temp][j]=true;
- document.getElementById("d_"+temp+"_"+j).style.background=tempcolor;
- }
- }
- }
- }
- function moveleft(obj) //左移 ← ←
- ...{
- if(canmove(obj,"left"))
- //if(true)
- ...{
- hid(obj);
- for(i=0;i<obj.length;i++)
- ...{
- obj.y[i]--;
- }
- show(obj);
- }
- }
- function moveright(obj) //右移 → →
- ...{
- if(canmove(obj,"right"))
- // if(true)
- ...{
- hid(obj);
- for(i=0;i<obj.length;i++)
- ...{
- obj.y[i]++;
- }
- show(obj);
- }
- }
- function turn(obj) //旋转
- ...{
- typ=obj.type;
- typ++;
- if(typ==4)...{typ=0;}
- styl=obj.style;
- temp_obj=obj_member[styl][typ];
- temp_obj.x[0]=obj.x[0];
- temp_obj.y[0]=obj.y[0];
- temp_obj.build();
- var can=true;
- for(h=0;h<temp_obj.legth;h++)
- ...{
- if(glo_statu[temp_obj.x[h]][temp_obj.y[h]]==true)
- ...{
- can=false;
- break;
- }
- }
- if(can)
- ...{
- hid(obj);
- now_obj=temp_obj;
- show(now_obj);
- }
- }
- function linesup() //抬升
- ...{hid(now_obj);
- for(i=2;i<TDX;i++)
- ...{
- for(j=1;j<TDY;j++)
- ...{
- if(glo_statu[i][j])
- ...{
- temp=i;
- var tempcolor=document.getElementById("d_"+i+"_"+j).style.background;
- document.getElementById("d_"+i+"_"+j).style.background=back_COLOR;
- glo_statu[temp][j]=false;
- temp--;
- glo_statu[temp][j]=true;
- // window.alert("d_"+temp+"_"+j);
- document.getElementById("d_"+temp+"_"+j).style.background=tempcolor;
- }
- }
- }
- for(j=1;j<TDY;j++)
- ...{
- randtemp=Math.floor(Math.random()*(2)); //window.alert(randtemp);
- if(randtemp==1)...{glo_statu[TDX-1][j]=true;document.getElementById("d_"+(TDX-1)+"_"+j).style.background="#CC00CC";}
- else ...{glo_statu[TDX-1][j]=false;document.getElementById("d_"+(TDX-1)+"_"+j).style.background=back_COLOR;}
- }
- show(now_obj);
- }
- //**********************************************************************************//
- document.write(" <div id=box align=center><div id=main><table>")
- var css;
- for(i=0;i<=TDX;i++)
- ...{
- document.write("<tr>")
- for(j=0;j<=TDY;j++)
- ...{
- if(j==0||j==TDY||i==TDX)...{css=side_COLOR;} else...{css=back_COLOR;}//围栏颜色
- document.write("<td id=d_"+i+"_"+j+" style="background:"+css+""></td>")
- }
- document.write("</tr>")
- }
- document.write("</table></div>");
- document.write("<div id=left><div id=left1><table>");
- for(i=0;i<5;i++)
- ...{
- document.write("<tr>")
- for(j=0;j<5;j++)
- ...{
- document.write("<td id=n_"+i+"_"+j+" style="background:"+next_back_COLOR+""></td>")
- }
- document.write("</tr>")
- }
- document.write("</table>");
- function fornext(obj,color) //显示/隐藏下一物体
- ...{
- if(color=="hidden")...{color=next_back_COLOR;}
- else if(color=="show")...{color=obj.color;}
- var px=new Array();
- var py=new Array();
- px[0]=2;py[0]=2;
- px[1]=px[0]+obj.getxy[0];
- py[1]=py[0]+obj.getxy[1];
- px[2]=px[0]+obj.getxy[2];
- py[2]=py[0]+obj.getxy[3];
- px[3]=px[0]+obj.getxy[4];
- py[3]=py[0]+obj.getxy[5];
- for(i=0;i<px.length;i++)
- document.getElementById("n_"+px[i]+"_"+py[i]).style.background=color;
- }
- fornext(next_obj,"show");
- function button(t) //按钮
- ...{
- if(t==msg_start)...{
- autodown(now_obj);
- document.getElementById("butt").value=msg_stop;
- mod=document.getElementById("mod").value;
- }
- else if(t==msg_stop)...{
- stop();
- document.getElementById("butt").value=msg_start;
- }
- else
- document.location.reload();
- document.body.focus();
- }
- pic="";
- for(k=1;k<=boom_num;k++)
- pic+="※ "
- </SCRIPT>
- <BR>
- 炸弹:<span id="boom"><SCRIPT LANGUAGE="JavaScript">document.write(pic);</SCRIPT></span>
- <BR>
- 行数: <span id="count_line">0</span><BR>
- 得分:<span id="count_score">0</span><BR>
- 等级:<span id="level">1</span>
- </div>
- <div id="left2">
- <div id="buttonkey">
- 升级后:
- <SELECT NAME="" id="mod" οnchange="mod=this.value;document.body.focus();">
- <OPTION VALUE="0" SELECTED>加 速</OPTION>
- <OPTION VALUE="1">加方块</OPTION>
- <OPTION VALUE="2">抬 升</OPTION>
- </SELECT>
- <br>
- <SCRIPT LANGUAGE="JavaScript">
- document.write("<INPUT TYPE="button" value=""+msg_start+"" id="butt" οnclick="button(this.value)">");
- </SCRIPT>
- <BR>
- </div><BR><BR><BR>
- 键盘<BR>
- ← ↓ → 移动<BR>
- ↑ 旋转<BR>
- 空格 使用炸弹
- </div>
- </div>
- </div>
- </P></BODY></HTML>
- <SCRIPT LANGUAGE="JavaScript">
- function boom() //炸弹
- ...{
- if(boom_num>0)
- ...{
- boom_num--;
- max=now_obj.x[0];
- for(i=1;i<now_obj.length;i++)
- ...{
- if(now_obj.x[i]>max)max=now_obj.x[i];
- }
- t=max+1;
- n=now_obj.y[0];
- while(glo_statu[t][n]==false)t++;
- for(i=n-3;i<=n+3;i++)
- ...{
- for(j=t-3;j<=t+3;j++)
- ...{
- if(i>0&&i<TDY&&j>0&&j<TDX)
- ...{
- glo_statu[j][i]=false;
- document.getElementById("d_"+j+"_"+i).style.background=back_COLOR;
- }
- }
- }
- pic="";
- for(k=1;k<=boom_num;k++)
- pic+=" ※"
- document.getElementById("boom").innerHTML=pic;
- //autodown();
- }
- }
- </SCRIPT>
javascript游戏-- 俄罗斯方块 源代码
最新推荐文章于 2024-04-08 12:21:33 发布