varfangxiang;fangxiang=4;varsk=newArray(18);sk[0]="5,"> varfangxiang;fangxiang=4;varsk=newArray(18);sk[0]="5," />
欢迎来到天天文库
浏览记录
ID:50949665
大小:69.50 KB
页数:14页
时间:2020-03-16
《HTML编写的贪吃蛇代码.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、
2、keyCode==38){if(fangxiang!=2)fangxiang=1;if(fangxiang==2)fangxiang=2;}if(event.keyCode==40){if(fangxiang!=1)fangxiang=2;if(fangxiang==1)fangxiang=1;}if(event.keyCode==37){if(fangxiang!=4)fangxiang=3;if(fangxiang==4)fangxiang=4;}if(event.keyCode==39){if(fangxiang!=3)fangxian
3、g=4;if(fangxiang==3)fangxiang=3;}}functionkaishi(){if(shifouchongzhi){shifouchongzhi=false;document.getElementById(sk[0]).style.backgroundColor="red";document.getElementById(sk[1]).style.backgroundColor="red";document.getElementById(sk[2]).style.backgroundColor="red";docume
4、nt.getElementById(shiwu).style.backgroundColor="blue";move();}elsealert("你要先重置");}functionchongzhi(){shifouchongzhi=true;shiwu="15,15";shudu=250;fangxiang=4;sk[0]="5,5";sk[1]="5,4";sk[2]="5,3";long=3;varm=document.getElementsByTagName("td");for(varn=0;n<400;n++){m[n].style.
5、backgroundColor="yellow";}movedong=true;}functiondong(){zhanshichunweiba=sk[long-1];for(varm=long-1;m>0;m--){sk[m]=sk[m-1]}vari=sk[0].split(',');if(fangxiang==1){i[0]--;sk[0]=i[0]+','+i[1]}if(fangxiang==2){i[0]++;sk[0]=i[0]+','+i[1]}if(fangxiang==3){i[1]--;sk[0]=i[0]+','+i[
6、1]}if(fangxiang==4){i[1]++;sk[0]=i[0]+','+i[1]}}functionzhenchanshengshiwu(){varx;vary;x=Math.round(Math.random()*19);y=Math.round(Math.random()*19);shiwu=x+','+y;chanshengshiwu();}functionchanshengshiwu(){for(varm=0;m7、t.getElementById(shiwu).style.backgroundColor="blue";}functionchishiwu(){if(shiwu==sk[0]){long++;sk[long-1]=zhanshichunweiba;document.getElementById(sk[long-1]).style.backgroundColor="red";chanshengshiwu();}}functionjieshujiashu(){vari=sk[0].split(',');if(i[0]<08、9、i[0]>1910、11、i12、[1]<013、14、i[1]>19){alert("你死求");movedong=false;}if(long>=6){shudu=200;}if(long>=9){sh
7、t.getElementById(shiwu).style.backgroundColor="blue";}functionchishiwu(){if(shiwu==sk[0]){long++;sk[long-1]=zhanshichunweiba;document.getElementById(sk[long-1]).style.backgroundColor="red";chanshengshiwu();}}functionjieshujiashu(){vari=sk[0].split(',');if(i[0]<0
8、
9、i[0]>19
10、
11、i
12、[1]<0
13、
14、i[1]>19){alert("你死求");movedong=false;}if(long>=6){shudu=200;}if(long>=9){sh
此文档下载收益归作者所有