网页版 扫雷 js

这是一个使用JavaScript编写的网页版扫雷游戏。通过HTML创建游戏区域,CSS进行样式设置,JS负责游戏逻辑,包括初始化雷区、点击和双击操作、判断游戏状态等功能。玩家可以通过单击标记雷区,双击翻开格子,游戏目标是找出所有非雷格子。
摘要由CSDN通过智能技术生成

//HTMEL

<body>

    <div class="content"> </div>
</body>

//css

.bottom,over {
    text-align: center;
    line-height: 0px;
}

    .bottom div {
        display: inline-block;
        width: 30px;
        height: 30px;
        border: 1px solid #808080;
        background-color: #f4a;
        text-align: center;
        font: 20px/30px arial;
    }

//JS

// 保存 初始雷化记录 和 拆雷记录  100个按钮中 有25个雷
var box = Array(10);

//初始化底层
function initBottom() {
    const content = document.getElementsByClassName('content')[0];
    const bottom = document.createElement('div');
    content.appendChild(bottom);
    bottom.className = "bottom";

    for (let i = 0; i < 10; i++) {
        box[i] = new Array(10);
        for (let j = 0; j < 10; j++) {
            const div = document.createElement('div');
            bottom.appendChild(div);
            div.id = "bottom[" + i + "][" + j + "]";
            box[i][j] = 0;
        }
        bottom.innerHTML = bottom.innerHTML + "<br />";
    }

    initB

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值