```javascript
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=400,maximum-scale=3.0,minimum-scale=0.5,user-scalable=no">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
html, body {
width: 100%;
height: 100%;
background: silver;
overflow: hidden;
}
.map {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
width: 400px;
height: 400px;
background: #fff5e7;
}
.hang {
height: 100px;
}
.hang > div {
width: 100px;
height: 100px;
border: 1px solid #000;
float: left;
box-sizing: border-box;
text-align: center;
font-size: 30px;
line-height: 100px;
color: #fff;
}
.color2 {
background: orange;
}
.color4 {
background: #ffef1b;
}
.color8 {
background: #f61bff;
}
.color16 {
background: #ff1f15;
}
.color32 {
background: #22bbff;
}
</style>
</head>
<body>
<div class="map">
</div>
<script src="js/jquery-1.9.1.js"></script>
<script>
/*
* 2048分析
* 画地图
* 构建地图数组
* */
//dom元素生成
//使用语法是jquery extend继承 合并对象
$.extend({
h_td: 4,
v_td: 4,
mapArray: [],
createDOM: function () {
for (var i = 0; i < this.h_td; i++) {
var array = [];
var div = $("<div></div>");
div.addClass("hang");
for (var k = 0; k < this.v_td; k++) {
var u_map = $("<div></div>");
u_map.addClass("user");
array.push(u_map);
div.append(u_map);
}
$(".map").append(div);
this.mapArray.push(array);
}
},
number: [2],
randomNum: function (arr) {
jq-2048小游戏
最新推荐文章于 2021-06-03 07:08:48 发布