嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
使用html css js编写的2048小游戏,使用键盘上下左右键进行移动
【页面截图】
// 模块化开发思路
var json={
// 创建初始化函数
init:function(){
var otab= document.querySelector('.tab'),
str='',
id=1;//返回文档指定的css元素,并保存
for(var i=0;i<4;i ){
str ='<tr>';
for(var j=0;j<4;j ){
str ='<td id="' id '"></td>';
}
str ='</tr>';
}
otab.innerHTML=str;
this.randomNum();
this.randomNum();
this.result();
},
//创建一个任意区间的随机函数
myRandom:function(min , max){
return Math.round(Math.random() * (max-min) min);
},
//随机在格子上生成一个数字
randomNum : function(){
var num = this.myRandom(1,16);
ogrid=document.getElementById(num);
if(ogrid.innerHTML ==''){
ogrid.innerHTML= this.myRandom(1,2)*2;
}else{
this.randomNum();
}
},