⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 月光软件站 - 编程文档 - script - javascript 寫遊戲 搬運工.htm

📁 javascript常见小游戏,谈吃蛇
💻 HTM
📖 第 1 页 / 共 2 页
字号:
            <P>&nbsp;</P>
            <P>function iBox(x,y,k){<BR>MainMap[y][x] = 
            Base.appendChild(document.createElement("&lt;span 
            style='position:absolute;left:"+x*MapW+";top:"+y*MapH+";width:"+MapW+";height:"+MapH+"' 
            class='Box' complete='"+k+"'&gt;"));<BR>TotalBox++;<BR>}</P>
            <P>function iMan(x,y,k){<BR>Man = 
            Base.appendChild(document.createElement("&lt;img alt='Man' 
            src='pic/BOXMAN.GIF' 
            style='position:absolute;left:"+x*MapW+";top:"+y*MapH+";width:"+MapW+";height:"+MapH+";' 
            class='Man'&gt;"));<BR>Man.x = x<BR>Man.y = y<BR>MainMap[y][x] = 
            (k==0)?' ':'.';<BR>}</P>
            <P>function Dir(x,y,k){<BR>if(!canMove) return<BR>var ManFront = 
            MainMap[y+parseInt(Man.y)][x+parseInt(Man.x)];<BR>if(ManFront==' ' 
            || ManFront=='.')if(k!=null)Move1(x,y,k.toLowerCase());else 
            Move1(x,y);<BR>else{<BR>&nbsp;if(typeof(ManFront)=='object'){<BR>&nbsp; 
            var ManFrontFront = 
            MainMap[2*y+parseInt(Man.y)][2*x+parseInt(Man.x)];<BR>&nbsp; 
            if(ManFrontFront == ' '){if(k!=null)Move1(x,y,k.toUpperCase());else 
            Move1(x,y);Move2(ManFront,x,y);}<BR>&nbsp; else if(ManFrontFront == 
            '.'){if(k!=null)Move1(x,y,k.toUpperCase());else 
            Move1(x,y);Move3(ManFront,x,y);}<BR>&nbsp; BoxMoves++<BR>&nbsp; 
            }<BR>&nbsp;}<BR>}</P>
            <P>&nbsp;</P>
            <P>&nbsp;</P>
            <P>&nbsp;</P>
            <P>function Move1(x,y,k){<BR>if(k != 
            null){<BR>&nbsp;BackRecord[++Count] = k<BR>&nbsp;BackRecord.length = 
            Count+1<BR>&nbsp;}<BR>Man.x = x+parseInt(Man.x);<BR>Man.y = 
            y+parseInt(Man.y);<BR>Man.style.left = Man.x*MapW;<BR>Man.style.top 
            = Man.y*MapH;<BR>}</P>
            <P>&nbsp;</P>
            <P>&nbsp;</P>
            <P><BR>function Move2(obj,x,y){<BR>obj.style.left = 
            (x+Man.x)*MapW;<BR>obj.style.top = 
            (y+Man.y)*MapH;<BR>MainMap[y+parseInt(Man.y)][x+parseInt(Man.x)] = 
            obj;<BR>if(obj.complete == 0) MainMap[Man.y][Man.x]=' 
            ';<BR>else{<BR>&nbsp;MainMap[Man.y][Man.x] = 
            '.';<BR>&nbsp;BoxCompletes --;<BR>&nbsp;}<BR>obj.complete = 
            0;<BR>}</P>
            <P>function Move3(obj,x,y){<BR>obj.style.left = 
            (x+Man.x)*MapW;<BR>obj.style.top = 
            (y+Man.y)*MapH;<BR>MainMap[y+parseInt(Man.y)][x+parseInt(Man.x)] = 
            obj;<BR>if(obj.complete == 1) 
            MainMap[Man.y][Man.x]='.';<BR>else{<BR>&nbsp;MainMap[Man.y][Man.x] = 
            ' ';<BR>&nbsp;if(++BoxCompletes == TotalBox) 
            oWin();<BR>&nbsp;}<BR>obj.complete = 1;<BR>}</P>
            <P><BR>function UnDo(){<BR>if(Count &gt;= 0){<BR>&nbsp;canMove = 
            true<BR>&nbsp;switch(BackRecord[Count]){<BR>&nbsp; //not 
            object<BR>&nbsp; case 'l':Move1(1,0);break;//left -&gt; 
            right<BR>&nbsp; case 'u':Move1(0,1);break;//up -&gt; down<BR>&nbsp; 
            case 'r':Move1(-1,0);break;//right -&gt; left<BR>&nbsp; case 
            'd':Move1(0,-1);break;//down -&gt; up<BR>&nbsp; //object<BR>&nbsp; 
            case 'L':UnGo(1,0);break;//left -&gt; right<BR>&nbsp; case 
            'U':UnGo(0,1);break;//up -&gt; down<BR>&nbsp; case 
            'R':UnGo(-1,0);break;//right -&gt; left<BR>&nbsp; case 
            'D':UnGo(0,-1);break;//down -&gt; up<BR>&nbsp; 
            }<BR>&nbsp;iSelects(--Count)<BR>&nbsp;}<BR>}</P>
            <P><BR>function UnGo(x,y){<BR>BoxMoves--;<BR>var obj = 
            MainMap[-y+parseInt(Man.y)][-x+parseInt(Man.x)];<BR>if(MainMap[Man.y][Man.x]==' 
            '){<BR>&nbsp;if(obj.complete == 
            0)MainMap[-y+parseInt(Man.y)][-x+parseInt(Man.x)]=' 
            ';<BR>&nbsp;else{<BR>&nbsp; 
            MainMap[-y+parseInt(Man.y)][-x+parseInt(Man.x)]='.';<BR>&nbsp; 
            BoxCompletes --;<BR>&nbsp; 
            }<BR>&nbsp;obj.complete=0<BR>&nbsp;}<BR>else{<BR>&nbsp;if(obj.complete 
            == 0){<BR>&nbsp; MainMap[-y+parseInt(Man.y)][-x+parseInt(Man.x)]=' 
            ';<BR>&nbsp; if(++BoxCompletes == TotalBox) oWin();<BR>&nbsp; 
            }<BR>&nbsp;else 
            MainMap[-y+parseInt(Man.y)][-x+parseInt(Man.x)]='.';<BR>&nbsp;obj.complete=1<BR>&nbsp;}<BR>obj.style.left 
            = Man.x*MapW;<BR>obj.style.top = 
            Man.y*MapH;<BR>MainMap[Man.y][Man.x] = obj;<BR>Move1(x,y);<BR>}</P>
            <P><BR>function 
            ReDo(){<BR>if(Count+1&lt;BackRecord.length){<BR>&nbsp;switch(BackRecord[++Count]){<BR>&nbsp; 
            case 'l': case 'L': Dir(-1,0);break;//left<BR>&nbsp; case 'u': case 
            'U': Dir(0,-1);break;//up<BR>&nbsp; case 'r': case 'R': 
            Dir(1,0);break;//right<BR>&nbsp; case 'd': case 'D': 
            Dir(0,1);break;//down<BR>&nbsp; 
            }<BR>&nbsp;iSelects(Count)<BR>&nbsp;}<BR>else 
            clearInterval(Timer);<BR>}</P>
            <P>&nbsp;</P>
            <P><BR>function oWin(){<BR>canMove = false<BR>alert('Congratulation! 
            You have pass.')<BR>}</P>
            <P>&nbsp;</P>
            <P>&nbsp;</P>
            <P><BR>function 
            window.onload(){<BR>ReadMap(0);<BR>document.body.scroll='no'</P>
            <P>function 
            document.onkeydown(){<BR>if(event.ctrlKey){<BR>&nbsp;switch(event.keyCode){<BR>&nbsp; 
            case 
            37:document.body.scrollLeft-=PushScrollNo;break;//left<BR>&nbsp; 
            case 38:document.body.scrollTop-=PushScrollNo;break;//up<BR>&nbsp; 
            case 
            39:document.body.scrollLeft+=PushScrollNo;break;//right<BR>&nbsp; 
            case 40:document.body.scrollTop+=PushScrollNo;break;//down<BR>&nbsp; 
            }<BR>&nbsp;}<BR>else{<BR>&nbsp;switch(event.keyCode){<BR>&nbsp; case 
            37:Dir(-1,0,'l');break;//left<BR>&nbsp; case 
            38:Dir(0,-1,'u');break;//up<BR>&nbsp; case 
            39:Dir(1,0,'r');break;//right<BR>&nbsp; case 
            40:Dir(0,1,'d');break;//down<BR>&nbsp; }<BR>&nbsp;event.returnValue 
            = false;<BR>&nbsp;Info.value = 
            BackRecord.join("")<BR>&nbsp;iSelects(Count)<BR>&nbsp;}<BR>}</P>
            <P>function document.onclick(){ReDo()}<BR>function 
            document.oncontextmenu(){UnDo();event.returnValue = false;}</P>
            <P>window.focus();<BR>Base.focus();<BR>}</P>
            <P>&nbsp;</P>
            <P>&nbsp;</P>
            <P>function Run(){<BR>var temp = Info.value;<BR>if(temp == 
            '')return;<BR>ReadMap(0);<BR>BackRecord=temp.split("")<BR>Timer = 
            setInterval(ReDo,RePlayTime)<BR>}</P>
            <P>function iSelects(x){<BR>var iRange = 
            Info.createTextRange()<BR>iRange.collapse(true)<BR>iRange.moveStart("character",x)<BR>iRange.moveEnd("character",1)<BR>iRange.select()<BR>BoxMoveInfo.value 
            = BoxMoves;<BR>ManMoveInfo.value = 
            x+1;<BR>}<BR>&lt;/script&gt;<BR></P><IMG height=1 
            src="月光软件站 - 编程文档 - Script - JavaScript 寫遊戲  搬運工.files/down_info.htm" 
            width=1 border=0><BR><BR></TD></TR>
        <TR>
          <TD width="100%" bgColor=#cccccc height=1></TD></TR>
        <TR>
          <TD width="100%"><BR><B>相关文章</B>:
            <P><B>相关软件</B>:</P></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></CENTER></DIV>
<CENTER>
<SCRIPT src="月光软件站 - 编程文档 - Script - JavaScript 寫遊戲  搬運工.files/bottom.js" 
type=text/javascript></SCRIPT>
</CENTER>
<DIV id=objbottom align=center>
<CENTER>
<SCRIPT type=text/javascript> 
var arrBaiduCproConfig=new Array(); 
arrBaiduCproConfig['uid'] =43125;
arrBaiduCproConfig['n'] ='williamlongcpr';
arrBaiduCproConfig['tm'] ='22';
arrBaiduCproConfig['cm'] ='72';
arrBaiduCproConfig['um'] ='22';
arrBaiduCproConfig['w'] ='728';
arrBaiduCproConfig['h'] ='90';
arrBaiduCproConfig['wn'] ='4';
arrBaiduCproConfig['hn'] ='1';
arrBaiduCproConfig['ta'] ='right';
arrBaiduCproConfig['tl'] ='bottom';
arrBaiduCproConfig['bu'] ='0';
arrBaiduCproConfig['bd'] ='#ffffff';
arrBaiduCproConfig['bg'] ='""';
arrBaiduCproConfig['tt'] ='#444444';
arrBaiduCproConfig['ct'] ='#000000';
arrBaiduCproConfig['url'] ='#000000';
arrBaiduCproConfig['bdl'] ='#ffffff';
arrBaiduCproConfig['rad'] =1;
</SCRIPT>

<SCRIPT src="月光软件站 - 编程文档 - Script - JavaScript 寫遊戲  搬運工.files/ui.js" 
type=text/javascript charset=gbk> 
</SCRIPT>

<SCRIPT type=text/javascript> 
<!-- 
document.write(baiduCproIFrame()); 
--> 
</SCRIPT>
</CENTER></DIV>
<SCRIPT language=javascript>
if(document.all.item("objtop") != null)
{
objtop.innerHTML = objbottom.innerHTML
}
</SCRIPT>
<BR><BR><BR>
<DIV align=center>
<CENTER>
<TABLE style="FONT-SIZE: 9pt" cellSpacing=0 cellPadding=1 width=770 border=0>
  <TBODY>
  <TR>
    <TD width=770 bgColor=#000000 height=1></TD></TR>
  <TR>
    <TD width=770 height=5></TD></TR>
  <TR>
    <TD align=middle width=770><A href="http://www.moon-soft.com/" 
      target=_top>月光软件</A>┊<A href="http://www.moon-soft.com/download/" 
      target=_top>程序下载</A>┊<A href="http://www.moon-soft.com/doc/" 
      target=_top>编程文档</A>┊<A href="http://www.moon-soft.com/book/" 
      target=_top>电脑教程</A>┊<A href="http://www.moon-soft.com/web/" 
      target=_top>网站设计</A>┊<A href="http://www.moon-soft.com/site/" 
      target=_top>网址导航</A>┊<A href="http://www.moon-soft.com/art/" 
      target=_top>网络文学</A>┊<A href="http://www.moon-soft.com/game/" 
      target=_top>游戏天地</A>┊<A href="http://www.moon-soft.com/joke/" 
      target=_top>幽默笑话</A>┊<A href="http://www.moon-soft.com/life/" 
      target=_top>生活休闲</A>┊<A href="http://www.moon-soft.com/picture/" 
      target=_top>美女图片</A>┊<A href="http://www.moon-soft.com/guestbook/" 
      target=_top>意见反馈</A><BR><A 
      href="http://www.moon-soft.com/program/bbs/docelite1105.htm">电脑技术</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite405353.htm">编程开发</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite25188.htm">网络专区</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite10811.htm">谈天说地</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite113108.htm">情感世界</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite872697.htm">游戏元素</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite50820.htm">分类游戏</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite166458.htm">热门游戏</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite42994.htm">体育运动</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite872698.htm">手机专区</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite28075.htm">业余爱好</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite34403.htm">影视沙龙</A><BR><A 
      href="http://www.moon-soft.com/program/bbs/docelite872701.htm">音乐天地</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite872702.htm">数码广场</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite121902.htm">教育园地</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite872703.htm">科学大观</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite991826.htm">古今纵横</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite49868.htm">谈股论金</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite55064.htm">人文艺术</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite165391.htm">医学保健</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite115338.htm">动漫图酷</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite872704.htm">二手专区</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite112364.htm">地方风情</A>┊<A 
      href="http://www.moon-soft.com/program/bbs/docelite165368.htm">各行各业</A><BR><BR><A 
      href="http://www.moon-soft.com/">月光软件站</A>·<A 
      href="http://www.moon-soft.com/sitemap.htm" target=_blank>版权所有</A> 
  </TD></TR></TBODY></TABLE></CENTER></DIV><BR><BR><BR><BR><BR><BR><!--  */  //--></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -