Главная » Файлы » Скрипты uCoz |
Игра: "Сломай стену"
13.12.2009, 13:01 | |
Игра старая и всем наверное знакомая. Смысл в том, чтобы разрушить Это ставим в head:
Code <script language="JavaScript"> <!-- var timerID = null var INT = 10 var loadFLG=0 var gameFLG=0 var missFLG=0 var tim = 0 //time var blcol = new Array(5) //block color var blsta = new Array(40) //block status var blclr = 0 //clear block var ballX = 0 //ball data var ballY = 0 var ballN = 3 var ballDX= 0 var ballDY= 0 var tmpRL = 193 var keyP=0 var keyPr=0 var endFLG=0 blcol[0]="#FFFF00" blcol[1]="#FFB000" blcol[2]="#FF8000" blcol[3]="#FF4000" blcol[4]="#FF0000" blcol[5]="#000000" var ieFLG=0 var n4FLG=0 if (document.all){ ieFLG=1 }else{ if (document.getElementById){ n4FLG=0 }else{ n4FLG=1 } } //----------------------------------------- //------------- main function ------------- //----------------------------------------- function mainF(){ clearTimeout(timerID) tim=tim+1 with (Math){tmptim=floor(tim/10)} tmptc="" tmptb=tim/10 if (tim==tmptim*10){tmptc=".0"} ballX=ballX+ballDX ballY=ballY+ballDY outCHK() blkCHK() if (document.getElementById){ document.SC.TM.value=tmptb+tmptc document.SC.CL.value=blclr document.SC.SR.value=blclr*200-tim document.getElementById("ball").style.top = ballY document.getElementById("ball").style.left = ballX }else{ if (ieFLG==1){ document.SC.TM.value=tmptb+tmptc document.SC.CL.value=blclr document.SC.SR.value=blclr*200-tim ball.style.posTop = ballY ball.style.posLeft = ballX }else{ document.layers["info"].document.forms[0].TM.value=tmptb+tmptc document.layers["info"].document.forms[0].CL.value=blclr document.layers["info"].document.forms[0].SR.value=blclr*200-tim document.layers["ball"].moveTo(ballX,ballY) } } racketMove() if (gameFLG==1){timerID = setTimeout("mainF()",INT)} } //----------------------------------------- //------------- sub functions ------------- //----------------------------------------- //game init function initG(){ keyP=0 if (endFLG == 0){ endFLG=1 blclr=0 tim=0 ballN=3 with (Math){tmptim=floor(tim/10)} if (document.getElementById){ document.SC.TM.value=tmptim document.getElementById("ovrmes").style.top=-1000 document.getElementById("clrmes").style.top=-1000 }else{ if (ieFLG==1){ document.SC.TM.value=tmptim clrmes.style.top=-1000 ovrmes.style.top=-1000 }else{ document.layers["info"].document.forms[0].TM.value=tmptim document.layers["ovrmes"].visibility="HIDE" document.layers["clrmes"].visibility="HIDE" } } for (ib=0; ib<5; ib++){for (ia=0; ia<8; ia++){ tmpIDn=ib*8+ia+1 if (document.getElementById){ document.getElementById(tmpIDn).style.backgroundColor = blcol[ib] }else{ if (ieFLG==1){ document.all(tmpIDn+9).style.backgroundColor = blcol[ib] }else{ document.layers[tmpIDn].bgColor=blcol[ib] } } blsta[ib*8+ia]=ib }} } if (document.getElementById){ document.SC.BL.value=ballN document.getElementById("starter").style.top=-1000 }else{ if (ieFLG==1){ document.SC.BL.value=ballN starter.style.top=-1000 }else{ document.layers["info"].document.forms[0].BL.value=ballN document.layers["starter"].visibility="HIDE" } } gameFLG=1;loadFLG=1 ballX=209;ballY=270;ballDX=-8;ballDY=-8;tmpRL=193;missFLG=0 timerID = setTimeout("mainF()",INT) } function keyDown(DnEvents){ if (ieFLG==0){ k=DnEvents.which }else{ k=window.event.keyCode } if (k == 39){keyP=5} //Cursor Right if (k == 76){keyP=5} //cursor right if (k == 37){keyP=-5} //Cursor Left if (k == 74){keyP=-5} //cursor left if (k == 32){if (gameFLG==0){initG()}} //Space if (k == 80){if (gameFLG==0){initG()}} //space } function keyUp(UpEvents){ if (ieFLG==0){ k=UpEvents.which }else{ k=window.event.keyCode } if (k == 39){keyP=0} //6 if (k == 37 ){keyP=0} //4 if (k == 76){keyP=0} //6 if (k == 74 ){keyP=0} //4 } //racket move function racketMove(){ if (loadFLG==1){ if (keyP != 0){ tmpkeyP=keyP*keyPr if (tmpkeyP>=0){ if (keyPr != 0){ if (Math.abs(keyPr)<15){keyPr=keyPr*1.2} }else{ keyPr=keyP } }else{ keyPr=keyP } }else{ keyPr=0 } tmpRL=tmpRL+keyPr if (tmpRL<16){tmpRL=16} if (tmpRL>370){tmpRL=370} if (document.getElementById){ document.getElementById("racket").style.left=tmpRL }else{ if (ieFLG==1){ racket.style.left=tmpRL }else{ document.layers["racket"].left=tmpRL } } } } //wall and racket check function outCHK(){ if (ballX < 16){ballX=32-ballX;ballDX=-ballDX} if (ballX > 401){ballX=802-ballX;ballDX=-ballDX} if (ballY < 16){ballY=32-ballY;ballDY=-ballDY} if (ballY >= 272){ if (missFLG==0){ tmpX=(ballDX/ballDY)*(272-ballY)+ballX if (tmpX >= tmpRL-12){ if (tmpX <= tmpRL+42){ ballY=272;ballDY=-ballDY ballX=tmpX ballRD=tmpX-tmpRL with (Math){ballDX=8*abs(ballDX)/ballDX} if (ballRD<-4){ballDX=-15} if (ballRD>36){ballDX=15} if (ballRD>=14){if (ballRD<=16){ballDX=-2}} if (ballRD>=17){if (ballRD<=20){ballDX=2}} if (ballRD>=0){if (ballRD<=4){ballDX=-4}} if (ballRD>=28){if (ballRD<=32){ballDX=4}} if (ballRD>=-4){if (ballRD<=-1){ballDX=-11}} if (ballRD>=33){if (ballRD<=36){ballDX=11}} } } if (ballDY>0){missFLG=1} }else{ if (ballY>290){missFLG=0;ballN=ballN-1;gameEnd()} } } } //block check function blkCHK(){ tmpY=ballY+4;tmpX=ballX+4 if (tmpY>=48){if (tmpY<=147){if (tmpX>=29){if (tmpX<=396){ with (Math) { ia=floor((tmpX-29)/46);ib=floor((tmpY-48)/20);ic=ib*8+ia } if (blsta[ic]<=4){ tmpbc=blsta[ic]+1 blsta[ic]=tmpbc tmpIDnc=ic+1 if (document.getElementById){ document.getElementById(tmpIDnc).style.backgroundColor = blcol[tmpbc] }else{ if (ieFLG==1){ document.all(tmpIDnc+9).style.backgroundColor = blcol[tmpbc] }else{ document.layers[tmpIDnc].bgColor=blcol[tmpbc] } } if (tmpbc==5){blclr=blclr+1} if (blclr >= 40){gameEnd()} if (ballDX>0){ iy=(ballDY/ballDX)*(29+46*ia-tmpX)+tmpY if (iy>48+20*ib+18){ tmpY1=48+20*ib+18 tmpX1=(ballDX/ballDY)*(48+20*ib+18-tmpY)+tmpX ballX=tmpX1-4;ballY=tmpY1-4 ballDY=-ballDY }else{ if (iy<44+20*ib){ tmpY1=48+20*ib tmpX1=(ballDX/ballDY)*(48+20*ib-tmpY)+tmpX ballX=tmpX1-4;ballY=tmpY1-4 ballDY=-ballDY }else{ tmpX1=29+46*ia tmpY1=(ballDY/ballDX)*(29+46*ia-tmpX)+tmpY ballX=tmpX1-4;ballY=tmpY1-4 ballDX=-ballDX } } }else{ iy=(ballDY/ballDX)*(29+46*ia+44-tmpX)+tmpY if (iy>48+20*ib+18){ tmpY1=48+20*ib+18 tmpX1=(ballDX/ballDY)*(48+20*ib+18-tmpY)+tmpX ballX=tmpX1-4;ballY=tmpY1-4 ballDY=-ballDY }else{ if (iy<44+20*ib){ tmpY1=48+20*ib tmpX1=(ballDX/ballDY)*(48+20*ib-tmpY)+tmpX ballX=tmpX1-4;ballY=tmpY1-4 ballDY=-ballDY }else{ tmpX1=29+46*ia+44 tmpY1=(ballDY/ballDX)*(29+46*ia+44-tmpX)+tmpY ballX=tmpX1-4;ballY=tmpY1-4 ballDX=-ballDX } } } } }}}} } //game end function gameEnd(){ gameFLG=0 loadFLG=0 if (document.getElementById){ document.SC.BL.value=ballN document.getElementById("starter").style.top=200 if (blclr >= 40){ document.getElementById("clrmes").style.top=150 endFLG=0 } if (ballN <= 0){ document.getElementById("ovrmes").style.top=160 endFLG=0 } }else{ if (ieFLG==1){ document.SC.BL.value=ballN starter.style.top=200 if (blclr >= 40){ clrmes.style.top=150 endFLG=0 } if (ballN <= 0){ ovrmes.style.top=160 endFLG=0 } }else{ document.layers["info"].document.forms[0].BL.value=ballN document.layers["starter"].visibility="SHOW" if (blclr >= 40){ document.layers["clrmes"].visibility="SHOW" endFLG=0 } if (ballN <= 0){ document.layers["ovrmes"].visibility="SHOW" endFLG=0 } } } } //Event init function onLD(){ document.onkeydown = keyDown document.onkeyup = keyUp if (document.getElementById){ document.getElementById("starter").style.top=200 document.getElementById("info").style.top=16 }else{ if (ieFLG==1){ starter.style.top=200 info.style.top=16 }else{ document.layers["starter"].visibility="SHOW" } } if (n4FLG!=0){document.captureEvents(Event.KEYDOWN|Event.KEYUP)} } var ie4 = (document.all) ? true : false; var nn4 = (document.layers) ? true : false; //--> </script> заменяем на это:
Code <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#7F007F" ALINK="#FF0000" onload="onLD()" ?> <a name="t0"><div id="gamewindow" style="BACKGROUND-COLOR: #000000; HEIGHT: 300px; LEFT: 16px; POSITION: absolute; TOP: 16px; WIDTH: 394px"><LAYER BGCOLOR="#000000" CLIP="0,0,393,299"> </LAYER> </div><script language="JavaScript"> <!-- //block layer write for (ib=0; ib<5; ib++){ for (ia=0; ia<8; ia++){ tmpL=31+46*ia;tmpT=50+20*ib tmpIDn=ib*8+ia+1 if (n4FLG!=1){ document.write("<DIV ID='"+tmpIDn+"' STYLE='position:absolute; background-color:"+blcol[ib]+"; top:"+tmpT+"px; left:"+tmpL+"px; width:42; height:16; clip:rect(0,43,17,0)'></DIV>") }else{ document.write("<LAYER LEFT="+tmpL+" TOP="+tmpT+" CLIP='1,1,43,17' BGCOLOR='"+blcol[ib]+"'></LAYER>") } blsta[ib*8+ia]=ib } } //--> </script> <div id="ball" style="HEIGHT: 8px; LEFT: 209px; POSITION: absolute; TOP: 270px; WIDTH: 8px"><div style="BACKGROUND-COLOR: #b0b0b0; CLIP: rect(0px 3px 7px 0px); HEIGHT: 8px; LEFT: 2px; POSITION: absolute; TOP: 0px; WIDTH: 4px"></div><div style="BACKGROUND-COLOR: #b0b0b0; CLIP: rect(0px 7px 3px 0px); HEIGHT: 4px; LEFT: 0px; POSITION: absolute; TOP: 2px; WIDTH: 8px"></div><div style="BACKGROUND-COLOR: #ffffff; CLIP: rect(0px 5px 5px 0px); HEIGHT: 6px; LEFT: 1px; POSITION: absolute; TOP: 1px; WIDTH: 6px"></div></div><div id="racket" style="BACKGROUND-COLOR: #b0b0ff; CLIP: rect(0px 39px 3px 0px); HEIGHT: 4px; LEFT: 193px; POSITION: absolute; TOP: 280px; WIDTH: 40px"></div><script language="JavaScript"> <!-- if (n4FLG==1){ document.write('<LAYER NAME="ball" LEFT="209" TOP="270" CLIP="0,0,7,7"> <LAYER LEFT="2" TOP="0" CLIP="0,0,3,7" BGCOLOR="#B0B0B0"></LAYER><LAYER LEFT="0" TOP="2" CLIP="0,0,7,3" BGCOLOR="#B0B0B0"></LAYER><LAYER LEFT="1" TOP="1" CLIP="0,0,5,5" BGCOLOR="#FFFFFF"></LAYER></LAYER><LAYER NAME="racket" LEFT="193" TOP="280" CLIP="0,0,39,3" BGCOLOR="#B0B0FF"></LAYER><LAYER NAME="info" LEFT="416" TOP="16">') }else{ document.write('<DIV ID="info" STYLE="position:absolute; top:-1000px; left:416px">') } //--> </script> <form name="SC"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td><font face="MS Sans Serif" size="1">Попыток: </font></td> <td><font face="MS Sans Serif" size="1"><input name="BL" size="5" value="3" style="font-family: MS Sans Serif; font-size: 1"></font></td> </tr> <tr> <td><font face="MS Sans Serif" size="1">Время: </font></td> <td><font face="MS Sans Serif" size="1"><input name="TM" size="5" value="0" style="font-family: MS Sans Serif; font-size: 1"></font></td> </tr> <tr> <td><font face="MS Sans Serif" size="1">БЛОК:</font></td> <td><font face="MS Sans Serif" size="1"><input name="CL" size="5" value="0" style="font-family: MS Sans Serif; font-size: 1"></font></td> </tr> <tr> <td><font face="MS Sans Serif" size="1">Очки:</font></td> <td><font face="MS Sans Serif" size="1"><input name="SR" size="5" value="0" style="font-family: MS Sans Serif; font-size: 1"></font></td> </tr> </table> </form> <script language="JavaScript"> <!-- if (n4FLG==1){ document.write('</LAYER><LAYER NAME="clrmes" TOP=150 LEFT=160 visibility="HIDE">') }else{ document.write('</DIV><DIV ID="clrmes" STYLE="position:absolute; top:-1000px; left:160px; visibility:visible">') } //--> </script> <font size="+1" face="Verdana" color="#44cc44" style="FONT-SIZE: 24px"> Вы всё очистили!</font> <script language="JavaScript"> <!-- if (n4FLG==1){ document.write('</LAYER><LAYER NAME="ovrmes" TOP=150 LEFT=160 visibility="HIDE">') }else{ document.write('</DIV><DIV ID="ovrmes" STYLE="position:absolute; top:-1000px; left:160px; visibility:visible">') } //--> </script> <font size="+1" face="Verdana" color="#cc4444" style="FONT-SIZE: 24px">Вы проиграли!</font> <script language="JavaScript"> <!-- if (n4FLG==1){ document.write('</LAYER><LAYER NAME="starter" TOP=200 LEFT=180 visibility="HIDE"><FONT COLOR="#FFFFFF">') }else{ document.write('</DIV><DIV ID="starter" STYLE="position:absolute; top:-1000px; left:180px; color:#FFFFFF; visibility:visible">') } //--> </script> <font face="MS Sans Serif" size="1">Влево = Курсор ВЛЕВО<br> Вправо = Курсор ВПРАВО<br> Старт = ПРОБЕЛ</font></p> | |
Просмотров: 615 | Загрузок: 0 | Рейтинг: 0.0/0 |
Всего комментариев: 0 | |