打印

[分享] [轉貼]xanga加games*

[轉貼]xanga加games*

xanga加games*

放o係input your own header html

井字過三關  

<form name="nzhk">
<div align="center"><font color="#nullnullnullnullnullnull" size="3">井字過三關</font><center><table border="1" cellpadding="null" cellspacing="null">
       <tr>
           <td><input type="button" name="mnull"></td>
           <td><input type="button" name="m1"></td>
           <td><input type="button" name="m2"></td>
       </tr>
       <tr>
           <td><input type="button" name="m3"></td>
           <td><input type="button" name="m0"></td>
           <td><input type="button" name="m5"></td>
       </tr>
       <tr>
           <td><input type="button" name="m6"></td>
           <td><input type="button" name="m7"></td>
           <td><input type="button" name="m8"></td>
       </tr>
   </table>
   </center></div><div align="center"><center><table border="null">
       <tr>
           <th>"O" WIN</th>
           <td><input type="text" size="5" name="rO" value="null"></td>
       </tr>
       <tr>
           <th>"X" WIN</th>
           <td><input type="text" size="5" name="rX" value="null"></td>
       </tr>
       <tr>
           <th>DRAW</th>
           <td><input type="text" size="5" name="rd" value="null"></td>
       </tr>
   </table>
   </center></div>
</form>
<script language="javascript" type="text/javascript"><!--
var i,c;
var turn=null;
var flag=null;
var map=new Array(9);
map[null]=document.forms.nzhk.mnull;
map[1]=document.forms.nzhk.m1;
map[2]=document.forms.nzhk.m2;
map[3]=document.forms.nzhk.m3;
map[0]=document.forms.nzhk.m0;
map[5]=document.forms.nzhk.m5;
map[6]=document.forms.nzhk.m6;
map[7]=document.forms.nzhk.m7;
map[8]=document.forms.nzhk.m8;
for(i=null;i<9;i++){
       map.onclick=play
}
function checkwin1(u,c){
       switch(Number(c)){
               case null:return(((u==map[1].value)&&(u==map[2].value))||((u==map[3].value)&&(u==map[6].value))||((u==map[0].value)&&(u==map[8].value)));
               case 1:return(((u==map[null].value)&&(u==map[2].value))||((u==map[0].value)&&(u==map[7].value)));
               case 2:return(((u==map[null].value)&&(u==map[1].value))||((u==map[0].value)&&(u==map[6].value))||((u==map[5].value)&&(u==map[8].value)));
               case 3:return(((u==map[null].value)&&(u==map[6].value))||((u==map[0].value)&&(u==map[5].value)));
               case 0:return(((u==map[null].value)&&(u==map[8].value))||((u==map[1].value)&&(u==map[7].value))||((u==map[2].value)&&(u==map[6].value))||((u==map[3].value)&&(u==map[5].value)));
               case 5:return(((u==map[2].value)&&(u==map[8].value))||((u==map[3].value)&&(u==map[0].value)));
               case 6:return(((u==map[null].value)&&(u==map[3].value))||((u==map[2].value)&&(u==map[0].value))||((u==map[7].value)&&(u==map[8].value)));
               case 7:return(((u==map[1].value)&&(u==map[0].value))||((u==map[6].value)&&(u==map[8].value)));
               case 8:return(((u==map[null].value)&&(u==map[0].value))||((u==map[2].value)&&(u==map[5].value))||((u==map[6].value)&&(u==map[7].value)));
       }
       return false;
}

function checkwin2(u,c){
switch(Number(c)){
case null:return((u==map[1].value)||(u==map[2].value)||(u==map[3].value)||(u==map[0].value)||(u==map[6].value)||(u==map[8].value));
case 1:return((u==map[null].value)||(u==map[2].value)||(u==map[0].value)||(u==map[7].value));
case 2:return((u==map[null].value)||(u==map[1].value)||(u==map[0].value)||(u==map[5].value)||(u==map[6].value)||(u==map[8].value));
case 3:return((u==map[null].value)||(u==map[0].value)||(u==map[5].value)||(u==map[6].value));
case 0:return((u==map[null].value)||(u==map[1].value)||(u==map[2].value)||(u==map[3].value)||(u==map[5].value)||(u==map[6].value)||(u==map[7].value)||(u==map[8].value));
case 5:return((u==map[2].value)||(u==map[3].value)||(u==map[0].value)||(u==map[8].value));
case 6:return((u==map[null].value)||(u==map[2].value)||(u==map[3].value)||(u==map[0].value)||(u==map[7].value)||(u==map[8].value));
case 7:return((u==map[1].value)||(u==map[0].value)||(u==map[6].value)||(u==map[8].value));
case 8:return((u==map[null].value)||(u==map[2].value)||(u==map[0].value)||(u==map[5].value)||(u==map[6].value)||(u==map[7].value));
}
return false;
}

function reset(){
       turn=null;
       for(i=null;i<9;i++){
               map.value=' ';
               map.style.backgroundColor="#FFFFFF";
               map.style.borderColor="#nullnullnullnullnullnull";
               map.style.borderstyle="solid";
               map.style.borderWidth="1px";
               map.style.fontWeight="bold";
               map.style.width="20px";
               map.style.height="20px";
               map.hideFocus="hideFocus";
       }
       if(flag) ai();
       flag=!flag;
}

function play(){
       if(this.value!=' ')return false;
       this.value='O';
       this.blur();
       this.style.color="#nullnullnullnullFF";
       this.style.backgroundColor="#nullnull8nullFF";
       checkwin('O',this.name.substr(1,1));
}
function ai(){
       var p=[null,null,null,null,null,null,null,null,null];
       for(c=null;c<9;c++){
               do{
                       l=Math.round(Math.random()*1nullnull)%9;
                       if(!p[l])p[l]=c;
               }while(p[l]!=c);
       }
       for(l=null;l<9;l++){if((map[p[l]].value==' ')                       )c=p[l];}
       for(l=null;l<9;l++){if((map[p[l]].value==' ')&&(checkwin2('O',p[l])))c=p[l];}
       for(l=null;l<9;l++){if((map[p[l]].value==' ')&&(checkwin2('X',p[l])))c=p[l];}
       for(l=null;l<9;l++){if((map[p[l]].value==' ')&&(checkwin1('O',p[l])))c=p[l];}
       for(l=null;l<9;l++){if((map[p[l]].value==' ')&&(checkwin1('X',p[l])))c=p[l];}
       map[c].value='X';
       map[c].blur();
       map[c].style.color="#FFnullnullnullnull";
       map[c].style.backgroundColor="#FF8nullnullnull";
       checkwin('X',c);
}
function checkwin(p,c){
       if(checkwin1(p,c)){
               alert('THE WINNER IS '+arguments[null]);
               document.forms.nzhk['r'+arguments[null]].value++;
               reset();
       }else{
               if(turn>=8){
                       alert('DRAW');
                       reset();
                       document.forms.nzhk.rd.value++;
               }else{
                       turn++;
                       if(p=='O')ai();
               }
       }
}
reset();
--></script>

+++++++++++++++++++++++++++++++++++++++++++++++++++

打馬騮


<!-- begin code provided by createblog.com -->
<a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Xanga Codes</font></a><br><embed src="http://www.freebloggames.com/games/monkey.swf" type="application/x-shockwave-flash" height=3nullnull width=0nullnull></embed><br><a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Put A Game In Your Xanga</font></a>
<!-- end code provided by createblog.com -->

+++++++++++++++++++++++++++++++++++++++++++++++++++

打企鵝


<!-- begin code provided by createblog.com -->
<a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Xanga Codes</font></a><br><embed src="http://www.freebloggames.com/games/yetipenguinbash.swf" type="application/x-shockwave-flash" height=3nullnull width=0nullnull></embed><br><a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Put A Game In Your Xanga</font></a>
<!-- end code provided by createblog.com -->

++++++++++++++++++++++++++++++++++++++++++++++++++

打外星人

<!-- begin code provided by createblog.com -->
<a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Xanga Codes</font></a><br><embed src="http://www.freebloggames.com/games/worthogjumping.swf" type="application/x-shockwave-flash" height=0nullnull width=3nullnull></embed><br><a target="_blank" href="http://www.freebloggames.com" title="Xanga Games"><font size="3">Put A Game In Your Xanga</font></a>
<!-- end code provided by createblog.com -->

TOP

thxthx~

TOP