js实现扫雷游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现扫雷游戏代码

代码标签: 游戏

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body{text-align: center;}
    tr{margin: 0 auto;padding: 0!important;margin: 0!important;}
    tr td{width: 20px;height: 20px;display: inline-block;box-shadow: 0px 0px 0px 0.3px #777;margin: 0;padding: 0;text-align: center;background: #c6d8dc;color: #777;font-size: 8px;line-height: 20px;}
    table{display: inline-block;margin: 0 auto;background: #c6d8dc;}
    .zero{background: #c6d8aa;}
    .one{color: deepskyblue;}
    .two{color: forestgreen;}
    .three{color: hotpink;}
    .four{color: #777;}
    .five{color: chocolate;}
    .six{color: crimson;}
    .seven{color: darkmagenta;}
    .eight{color: deeppink;}
    .mine{background:url(img/timg.png) no-repeat;background-size: 100%;}
    .onlyMine{background:url(img/timg1.png) no-repeat;background-size: 100%;}
    .flag{background: url(img/QQ20200312-212956@2x.png) 5px 2px no-repeat;background-size: 70%;}
    button{background: #c6d8aa;color: white;font-size: 10px;margin-bottom: 20px;margin-top: 10px;;}
    span{font-size: 10px;;}
    p{font-size: 10px;}
    a{text-decoration: none;color: white;background: red;padding: 2px 10px;font-size: 10px;}
    </style>
</head>

<body>
    <div>
        <button id='chuji'>初级</button>
        <button id='zhongji'>中级</button>
        <button id='gaoji'>高级</button>
        <span id='span'></span>
        <span>剩余雷的数量:</span><span id='num'></span>
        <a href="javascript:void(0)">重新开始游戏</a>

    </div>
    <div id='box'></div>


    <script>
        //创建一个棋盘的构造函数
        function Mine(tr, td, mineNum, count) {
            this.tr = tr;//棋盘行数
            this.td = td;//棋盘列数
            this.mineNum = mineNum;//雷的数量
            this.squares = [];//用于存储每个方块的信息
            this.tds = [];//存储每一个td的dom对象;
            this.setMine = mineNum;
            this.surplusMine = this.setMine;//存储剩余雷的数量;
            this.allRight = false;//雷是否被全部找出来
            this.parent = document.getElementById("box");//棋盘容器
            this.count = count;//存储玩家.........完整代码请登录后点击上方下载按钮下载查看

网友评论0