js实现简单的类似羊了个羊消除游戏代码
代码语言:html
所属分类:游戏
代码描述:js实现简单的类似羊了个羊消除游戏代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>羊了个羊</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.main {
position: relative;
}
.item {
position: absolute;
background: no-repeat center center #ffffff;
border:1px solid #ddd;
background-size: 100%;
color: transparent;
display: flex;
justify-content: center;
align-items: center;
z-index: 0;
transition: left .3s, top .3s, transform .3s;
}
.item:after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
transition: background-color .2s;
}
.disabled:after {
background-color: rgba(0,0,0,0.7);
}
.move-list {
border: 1px solid #ddd;
background-color: #ddd;
margin:0 auto;
}
</style>
</head>
<body>
<div class="main">
</div>
<div class="move-list">
</div>
<script>
// 基础数据
const simpleData = [
{name: '虎', color: '#ff1100', bg: '//repo.bfw.wiki/bfwrepo/images/yang/1.png'},
{name: '兔', color: '#ff8800', bg: '//repo.bfw.wiki/bfwrepo/images/yang/2.png'},
{name: '牛', color: 'green', bg: '//repo.bfw.wiki/bfwrepo/images/yang/3.png'},
{name: '羊', color: 'blue', bg: '//repo.bfw.wiki/bfwrepo/images/yang/4.png'},
{name: '蛇', color: '#779922', bg: '//repo.bfw.wiki/bfwrepo/images/yang/5.png'},
{name: '鼠', color: '#335577', bg: '//repo.bfw.wiki/bfwrepo/images/yang/6.png'}
]
// 卡片大小
const size = 40
// 矩阵行
const rows = 10
// 矩阵列
const cols = 10
// 每组为3个
const oneGoupCount = 3
// 每个卡片有x组
const group = 6
// 总共6层,即6个表格
const layerCount = 6
// 表格html
const cellHtml = []
// 将生成所有的十二生肖
const renderData = Array.from(new Array(oneGoupCount * group)).map(v => {
return simpleData.map(v => .........完整代码请登录后点击上方下载按钮下载查看
网友评论0