JavaScript实现经典消方块游戏

2023-11-06

诶哟图丢了

操作方式

在游戏区域中任意位置滑动手势,点击屏幕下方的按钮,键盘WASD都可以操作。

游戏动作 操作
方块向左移动 左划、按下蓝色键(左一)、A
方块向右移动 右划、按下橙色键(右一)、D
强制方块下落 下划、按下粉色键(左二)、S
改变方块方向 上划或轻触、按下绿色键(右二)、W

游戏内容

初始化游戏区域啥都没有,每种方块面积都是4个方格,如果水平一行充满方块那么这一行就被整体消去,否则方块堆积越来越高直到超过一个阈值使游戏结束。每消一行加一分,同时游戏速度提高10ms。整个游戏就一个文件,浏览器打开。颜色好看。

代码

用了es6的语法,浏览器不能太老。

<!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, maximum-scale=1.0, user-scalable=0;" />
    <title>Demo</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            user-select: none;
        }

        body {
            overflow: hidden;
        }

        #win {
            height: 75vh;
        }

        @media only screen and(min-aspect-ratio:1/1) {
            #win {
                height: 80vmin;
            }
        }

        #peek {
            max-height: 100%;
            max-width: 100%;
        }

        #score {
            font-family: sans-serif;
            font-size: 30px;
            text-align: center;
            padding: 0.5rem 0;
        }

        .container {
            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
        }

        .flex {
            display: flex;
        }

        .center {
            justify-content: space-around;
        }

        #toolbox>* {
            text-align: center;
            font-size: 7.5vmin;
            width: 15vmin;
            height: 15vmin;
            line-height: 15vmin;
        }

        #toolbox>div {
            border-radius: 20%;
            transition: background linear 0.5s;
        }

        #toolbox>div:active {
            background: #fff;
            transition: background linear 0s;
        }

        #toolbox>div svg {
            margin: 25%;
        }

        #toolbox>div svg * {
            fill: #fff;
        }
    </style>
</head>

<body>
    <div class="container">
        <div id="score"></div>
        <div class="flex center">
            <canvas id="win"></canvas>
        </div>
        <div>&emsp;</div>
        <div id="toolbox" class="flex center">
            <div onclick="handleButtonDown(65)" style="background: #08f;">
                <svg viewBox="0 0 10 10">
                    <polygon points="0,5 10,0 10,10" />
                </svg>
            </div>
            <div onclick="handleButtonDown(83)" style="background: #f08;">
                <svg viewBox="0 0 10 10">
                    <polygon points="0,0 10,0 5,10" />
                </svg>
            </div>
            <span>
                <canvas id="peek"></canvas>
            </span>
            <div onclick="handleButtonDown(87)" style="background: #8c0;">
                <svg viewBox="0 0 10 10">
                    <circle cx="5" cy="5" r="5" />
                </svg>
            </div>
            <div onclick="handleButtonDown(68)" style="background: #f80;">
                <svg viewBox="0 0 10 10">
                    <polygon points="0,10 0,0 10,5" />
                </svg>
            </div>
        </div>
        <div>&emsp;</div>
    </div>
</body>
<script>
    const BLOCKS = initBlockSet([
        [
            [0, 1, 1],
            [1, 0, 0],
        ], [
            [1, 1, 0],
            [0, 0, 1],
        ], [
            [1, 0, 1],
            [0, 1, 0],
        ], [
            [1, 1],
            [0, 1],
        ], [
            [1, 1, 1],
        ], [
            [1,],
        ] // 改这些数字还可以用不同面积的方块游戏,这是3块的
    ]);

    const GAME = document.getElementById('win');
    const PEEK = document.getElementById('peek');
    const SCORE = document.getElementById('score');
    const CTX = GAME.getContext('2' + 'd');
    const PEEK_CTX = PEEK.getContext('2' + 'd'); // 预览下一块
    const FLEX = 2;
    const WIDTH = 10; // 游戏屏幕宽度,单位是方格
    const HEIGHT = 18; // 游戏屏幕高度
    const INIT_DELAY = 400; // 初始游戏速度,值越小速度越快
    const SENSITIVITY = 50; // 移动端触屏滑动距离超过这个值就移动方块,否则改变方块方向
    const TOUCH_MOVE_DELAY = 50; // 连续滑动改为间歇

    // 添加触摸事件
    GAME.addEventListener('touchstart', handleHandDown, false);
    GAME.addEventListener('touchend', handleHandUp, false);
    GAME.addEventListener('touchmove', handleHandMove, false);

    // 初始化游戏和控制用变量~
    var game = Game();
    var lastTime = new Date().getTime();
    var lastMove = new Date().getTime();
    var blockSize = 10;
    var key = '';
    var touchX = 0;
    var touchY = 0;

    // 屏幕尺寸变化时canvas的图像可能失真,所以要计算一个格的宽度以便画出清晰的游戏画面
    function handleResize () {
        let rect = GAME.getBoundingClientRect();
        blockSize = GAME.offsetWidth / WIDTH;
    }

    // 用户操作时调用
    function handleHandDown (e) {
        e.preventDefault();
        let touch = e.touches[0] || e.changedTouches[0] || { clientX: e.clientX, clientY: e.clientX };
        touchX = touch.clientX;
        touchY = touch.clientY;

    }

    function handleHandMove (e) {
        let now = new Date().getTime();
        if (now - lastMove < TOUCH_MOVE_DELAY) {
            return false;
        }
        lastMove = now;
        let touch = e.touches[0] || e.changedTouches[0] || { clientX: e.clientX, clientY: e.clientX };
        if (touch.clientX - touchX > SENSITIVITY) {
            handleKeyDown({ keyCode: 68 })
        } else if (touchX - touch.clientX > SENSITIVITY) {
            handleKeyDown({ keyCode: 65 })
        }
    }

    function handleHandUp (e) {
        let touch = e.touches[0] || e.changedTouches[0] || { clientX: e.clientX, clientY: e.clientX };
        if (touch.clientX - touchX > SENSITIVITY) {
            handleKeyDown({ keyCode: 68 })
        } else if (touchX - touch.clientX > SENSITIVITY) {
            handleKeyDown({ keyCode: 65 })
        } else if (touch.clientY - touchY > SENSITIVITY) {
            handleKeyDown({ keyCode: 83 })
        } else if (touchY - touch.clientY >= 0) {
            handleKeyDown({ keyCode: 87 })
        }
    }

    function handleButtonDown (input) {
        handleKeyDown({ keyCode: input })
    }

    function handleKeyDown (e) {
        if (!game.isLiving()) {
            game = Game(); // 不判断按键,只要游戏结束,按任意键都能开局
            return;
        }
        switch (e.keyCode) {
            case 37:
            case 65:
                key = 'a';
                break;
            case 38:
            case 87:
                key = 'w';
                break;
            case 39:
            case 68:
                key = 'd';
                break;
            case 40:
            case 83:
                key = 's';
                break;
            default:
                key = '';
                break;
        }
    }

    // 初始化方块数据,计算各种方块不同方向的形状
    function initBlockSet (seed) {
        const FANCY_COUNT = 4;
        let ret = [];
        for (let styleIndex = 0, styleCount = seed.length; styleIndex < styleCount; styleIndex++) {
            const model = [];
            let style = seed[styleIndex];
            for (let fancyIndex = 0; fancyIndex < FANCY_COUNT; fancyIndex++) {
                let fancy = [];
                for (let x = 0, w = style[0].length; x < w; x++) {
                    let line = [];
                    for (let y = style.length - 1; y >= 0; y--) {
                        const pixel = style[y][x];
                        line.push(pixel);
                    }
                    fancy.push(line);
                }
                model.push(fancy);
                style = fancy;
            }
            ret.push(model);
        }
        return ret;
    }

    // 初始化一个方块,颜色、方向、种类都随机,位置在屏幕顶端居中
    function initBlock (x, y, style, fancy, color) {
        return {
            color: color || `hsl(${Math.random() * 360},60%,70%)`,
            fancy: (fancy === undefined || fancy === null) ? Math.floor(Math.random() * 4) : fancy,
            style: (style === undefined || style === null) ? Math.floor(Math.random() * BLOCKS.length) : style,
            x: (x === undefined || x === null) ? Math.floor(WIDTH / 2) : x,
            y: (y === undefined || y === null) ? 0 : y,
        }
    }

    // 判断方块能否安放当前位置,若方块有一部分超出屏幕两侧或下端或者与其它已经放置的方块重合都返回false
    function canFill (block, map) {
        const model = BLOCKS[block.style][block.fancy % BLOCKS[block.style].length];
        const w = model[0].length;
        const h = model.length;
        const left = block.x - Math.floor(w / 2);
        const top = block.y - Math.floor(h / 2);
        for (let y = 0; y < h; y++) {
            const absoluteY = top + y;
            if (absoluteY < 0) {
                continue;
            }
            for (let x = 0; x < w; x++) {
                const absoluteX = left + x;
                const blockPoint = model[y][x];
                if (blockPoint) {
                    if (absoluteX < 0 || absoluteX >= WIDTH) {
                        return false;
                    }
                    if (absoluteY >= HEIGHT) {
                        return false;
                    }
                    const mapPoint = map[absoluteY] ? map[absoluteY][absoluteX] : false;
                    if (mapPoint) {
                        return false;
                    }
                }
            }
        }
        return true;
    }

    // 将活动的方块固定
    function fill (block, map) {
        const model = BLOCKS[block.style][block.fancy % BLOCKS[block.style].length];
        const w = model[0].length;
        const h = model.length
        const left = block.x - Math.floor(w / 2)
        const top = block.y - Math.floor(h / 2)
        for (let y = 0; y < h; y++) {
            for (let x = 0; x < w; x++) {
                const blockPoint = model[y][x];
                if (blockPoint && map[top + y]) {
                    map[top + y][left + x] = block.color;
                }
            }
        }
    }

    // 游戏“类”
    function Game () {
        let map = [];
        for (let y = 0; y < HEIGHT; y++) {
            map.push([]);
        }
        var bgColor = `hsla(${Math.random() * 360},100%,30%,0.05)`;
        var score = 0;
        var living = true;
        let hold = initBlock();
        let next = initBlock();
        let falling = false;
        let draw = function () {
            GAME.width = blockSize * WIDTH;
            GAME.height = blockSize * HEIGHT;
            for (let y = 0; y < HEIGHT; y++) {
                for (let x = 0; x < WIDTH; x++) {
                    if (map[y][x]) {
                        CTX.fillStyle = map[y][x];
                        CTX.fillRect(x * blockSize, y * blockSize, blockSize, blockSize);
                    } else if (x % 2 != y % 2) {
                        CTX.fillStyle = bgColor;
                        CTX.fillRect(x * blockSize, y * blockSize, blockSize, blockSize);
                    }
                }
            }
            let moving = BLOCKS[hold.style][hold.fancy % BLOCKS[hold.style].length];
            const w = moving[0].length;
            const h = moving.length;
            const left = hold.x - Math.floor(w / 2);
            const top = hold.y - Math.floor(h / 2);
            for (let y = 0; y < w; y++) {
                for (let x = 0; x < h; x++) {
                    if (moving[y][x]) {
                        CTX.fillStyle = hold.color;
                        CTX.fillRect((x + left) * blockSize, (y + top) * blockSize, blockSize, blockSize);
                    }
                }
            }
            let peek = BLOCKS[next.style][next.fancy % BLOCKS[next.style].length];
            PEEK.width = blockSize * peek[0].length;
            PEEK.height = blockSize * peek.length;
            for (let y = 0; y < peek.length; y++) {
                for (let x = 0; x < peek[0].length; x++) {
                    if (peek[y][x]) {
                        PEEK_CTX.fillStyle = next.color;
                        PEEK_CTX.fillRect(x * blockSize, y * blockSize, blockSize, blockSize);
                    }
                }
            }
            SCORE.innerHTML = score;
        }
        let control = function (key) {
            let moved = hold;
            switch (key) {
                case 'a':
                    moved = initBlock(hold.x - 1, hold.y, hold.style, hold.fancy, hold.color);
                    break;
                case 'w': // 改变了方块的方向将导致方块宽度和高度变化,原本能放下方块的空间可能放不下操作后的方块,需要专门判断
                    moved = initBlock(hold.x, hold.y, hold.style, hold.fancy + 1, hold.color);
                    if (canFill(moved, map)) {
                        break;
                    }
                    //不能移动,左右滑移1-2格判断是否能放置
                    for (let offset = 1, i = 0; offset <= FLEX; offset = (++i % 2 ? offset : (offset + 1)) * -1) {
                        let floating = initBlock(hold.x + offset, hold.y, hold.style, hold.fancy, hold.color);
                        if (canFill(floating, map)) {
                            moved = floating; // 滑移后能放置
                            break;
                        }
                    }
                    break;
                case 's':
                    falling = true;
                    break;
                case 'd':
                    moved = initBlock(hold.x + 1, hold.y, hold.style, hold.fancy, hold.color);
                    break;
            }
            if (canFill(moved, map)) {
                hold = moved; // 放置但不固定,它还没落到底
            }
        }
        let step = function () {
            if (!living) {
                falling = false;
                return;
            }
            let moved = initBlock(hold.x, hold.y + 1, hold.style, hold.fancy, hold.color); // 下降一格
            if (canFill(moved, map)) {
                hold = moved; // 如果下降一格后能放置就放置
            } else { // 如果不能,那么当前是能放置的且方块已经被其它方块或游戏屏幕底部阻挡
                if (map[0].length) { // 如果游戏区域第一行有已经固定的方块那么游戏结束
                    living = false;
                    falling = false;
                    return;
                }
                //将hold置入map
                fill(hold, map);
                hold = next;
                next = initBlock();
                key = '';
                falling = false;
            }
            let cleared = []
            for (let y = HEIGHT - 1; y >= 0; y--) {
                let filled = 0; // 计数,用来判断一行是不是已经满了
                for (let x = 0; x < WIDTH; x++) {
                    if (map[y][x]) {
                        filled++;
                    }
                }
                if (filled < WIDTH) {
                    cleared.unshift(map[y]); // 如果一行没满i就加入更新的游戏区域
                } else {
                    score++;
                }
            }
            while (cleared.length < HEIGHT) {
                cleared.unshift([]); // 补齐高度
            }
            map = cleared;
        }
        return {
            step: step,
            draw: draw,
            control: control,
            getScore: () => score,
            isLiving: () => living,
            isFalling: () => falling,
        };
    }
    function intervalCallback () {
        let now = new Date().getTime();
        // 根据游戏得分以及玩家的操作动态控制游戏进度更新频率
        if (now - lastTime >= INIT_DELAY - game.getScore() * 10 || game.isFalling()) {
            game.step();
            lastTime = new Date().getTime();
        }
        if (game.isLiving()) { // 只要游戏没有结束,就一直刷新,要不然一卡一卡的难受
            game.control(key);
            key = '';
            game.draw();
        }
        requestAnimationFrame(intervalCallback);
    }
    window.onresize = handleResize;
    window.onkeydown = handleKeyDown;
    requestAnimationFrame(intervalCallback);
    handleResize();
</script>

</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JavaScript实现经典消方块游戏 的相关文章

  • 从 thymeleaf 获取数据到模态引导程序、jquery

    我正在尝试获取模态视图的 id 这是为了更新 onclick 元素 但我找不到方法 知道如何为 boostrap 5 完成此操作 或我可以用其他方法吗 谢谢 tr a inactivate a div class modal fade mo
  • 将 OoXml 插入单词抛出错误:未知

    我一直在尝试通过office js将OOXML插入到word文档的正文内容中insertOoXML 方法 我什至尝试过最简单的实现 认为我在尝试替换 XML 本身中的 fieldCodes 时做了一些不正确的事情 所有结果都是这样Error
  • 使用 vscode 调试器调试 next.js

    我已经使用安装了一个项目创建下一个应用程序 https github com segmentio create next app 我需要使用我的编辑器 vscode 调试服务器端渲染 所以我访问过vscode recipes 如何调试 ne
  • React js Stripe 结账不起作用

    我正在尝试在 React js 应用程序中呈现条带结账默认表单
  • 了解设置 JQuery 变量

    了解设置 JQuery 变量 最近 我通过在 StackOverflow 上遇到的另一个问题寻找帮助 了解到如何设置 JQuery 变量 如下所示 您可以通过简单地调用变量来创建输入字段 并且锚变量似乎也定义了样式 var clicked
  • jquery.find() 可以只选择直接子项吗?

    我应该向 jQuery find 提供什么参数来选择元素子元素而不选择其他元素 我不能用 gt 引导选择器 而用 将选择所有后代 而不仅仅是直接子代 我知道 jQuery children 但这是一个库 因此用户能够提供自己的选择器 并且我
  • 在 Vue.js 中从父组件执行子方法

    目前 我有一个 Vue js 组件 其中包含其他组件的列表 我知道使用 vue 的常见方式是将数据传递给孩子 并从孩子向父母发出事件 但是 在这种情况下 我想在子组件中的按钮出现时执行子组件中的方法 parent被点击 哪种方法最好 一种建
  • 如何重定向到 instagram://user?username={username}

    我的 html 页面上有这个链接 可以在特定用户上打开 Instagram 应用程序 a href Link to Instagram Profile a 我一直在寻找自动运行 url instagram user username USE
  • 使用模数按字母顺序对列表进行排序

    我在获取元素列表并按字母顺序对它们进行排序方面没有任何问题 但我很难理解如何使用模数来做到这一点 更新 这是按我的方式工作的代码 但是 我更喜欢下面提供的答案的可重用性 因此接受了该答案
  • Meteor:应用程序无法在 0.9.1.1 版本上运行

    出现类似错误 Error TypeError undefined is not a function evaluating Template create anonymous function iron dynamic template j
  • Google App Engine:修改云运行环境

    我正在尝试部署一个使用自定义 Node js 服务器的 Next js 应用程序 我想将自定义构建变量注入应用程序 next config js const NODE ENV process env NODE ENV const envTy
  • 在requestAnimationFrame中使用clearRect不显示动画

    我正在尝试在 HTML5 画布上做一个简单的 javascript 动画 现在我的画布是分层的 这样当我收到鼠标事件时 背景层不会改变 但带有头像的顶层会移动 如果我使用 requestAnimationFrame 并且不清除屏幕 我会看到
  • 在 webpack 2.x 中使用 autoprefixer 和 postcss

    如何使用autoprefixer使用 webpack 2 x 以前 它曾经是这样的 module loaders test scss loader style css sass postcss postcss gt return autop
  • 如何使输入字段和提交按钮变灰

    我想变灰这两件事 http doorsplit heroku com 歌曲输入字段和提交按钮 直到用户输入艺术家 有没有一种简单的方法可以通过 JQuery 来做到这一点 艺术家输入字段的id是 request artist 你可以这样做
  • Angular 2+ 安全性;保护服务器上的延迟加载模块

    我有一个 Angular 2 应用程序 用户可以在其中输入个人数据 该数据在应用程序的另一部分进行分析 该部分仅适用于具有特定权限的人员 问题是我们不想让未经授权的人知道how我们正在分析这些数据 因此 如果他们能够在应用程序中查看模板 那
  • 为什么我不能在 AngularJS 中使用 data-* 作为指令的属性名称?

    On the t他的笨蛋 http plnkr co edit l3KoY3 p preview您可以注意到属性名称模式的奇怪行为data 在指令中 电话 Test of data named attribute br
  • 在 vue.js 中访问数组对象属性

    给定以下数组vue js packageMaps Object packageMap 0 Object Id 16 PackageType flag list ProductCode F BannerBase packageMap 1 Ob
  • Safari 支持 JavaScript window.onerror 吗?

    我有一个附加到 window onerror 的函数 window onerror function errorMsg url line window alert asdf 这在 firefox chrome 和 IE 中工作正常 但在 s
  • 如何仅在最后一个
  • 处给出透明六边形角度?
  • 我必须制作这样的菜单 替代文本 http shup com Shup 330421 1104422739 My Desktop png http shup com Shup 330421 1104422739 My Desktop png
  • 如何从图像输入中获取 xy 坐标?

    我有一个输入设置为图像类型

随机推荐

  • OPENCV4学习代码-Mat类构造与赋值

    代码清单2 4 默认构造函数使用方式 cv Mat Mat 代码清单2 5 利用矩阵尺寸和类型参数构造Mat类 cv Mat Mat int rows int cols int type 代码清单2 6 用Size 结构构造Mat类 cv
  • 华为机考笔记之字符串以水仙花规则拆分

    题目 一 输入一组字符串 求字符串分组后 每组的和为水仙花数 注 水仙花数是一个三位数 其个位 十位 百位的立次方 的和等于自身 如 371 3 3 7 3 1 1 1 如果无法找到该分组 返回0 2 找到该分组 切分组不唯一 返回 1 3
  • js 每隔 10 秒钟 运行一次,发送一个 ajax 请求

    每隔 10 秒钟 运行一次 发送一个 ajax 请求 function runEvery10Sec 1000 10 10 秒钟 setTimeout runEvery10Sec 1000 10 ajax dataType json type
  • jQuery取得select选中的值

    jQuery取得select选中的值 本来以为jQuery select1 val 是取得选中的值 那么jQuery select1 text 就是取得的文本 这是不正确的 正确做法是 jQuery select1 option selec
  • Qt中的单例模式:实现一个单例的界面类

    文章目录 前言 一 什么是单例模式 二 单例模式的优缺点及使用场景 三 Qt中单例类的创建 四 单例类的使用 测试 总结 前言 本文主要讲述了使用加锁的懒汉式来实现单例 文中示例将一个界面类修改为单例类 并在主界面获取多次该类的实例来进行测
  • 统计一个字符串中大写字母字符,小写字母字符,数字字符出现的次数

    统计一个字符串中大写字母字符 小写字母字符 数字字符出现的次数 不考虑其他字符 1 需求 统计一个字符串中大写字母字符 小写字母字符 数字字符出现的次数 不考虑其他字符 举例 Hello123World 结果 大写字符 2个 小写字符 8个
  • IDEA中常用的插件

    目录 Free MyBatis plugin codehelper generator grep console Translation Alibaba Java Coding Guidelines CamelCase GenerateAl
  • unordered_map的哈希HASH重载——举例unordered_map与pair联合使用

    有些时候 为了图省力 我们没准会这样的调用一个函数 unordered map lt pair
  • 分子模拟—Ovito渲染案例教程

    heartsuit spadesuit 分子模拟 Ovito渲染案例教程 heartsuit
  • 利用Nodejs 构建 WEB服务器

    前言 Web 服务器一般指网站服务器 是指驻留于因特网上某种类型计算机的程序 可以 向浏览器等 Web 客户端提供文档 也可以放置网站文件 让全世界浏览 可以放置数据文件 让全世界下载 目前最主流的三个 Web 服务器是 Apache Ng
  • 运算放大器芯片输出扩流电路三例

    工作原理 图1所示为三种集成运算放大器输出电流扩展电路 图 a 为双极性扩展电路 图 b 图 c 为单极性扩展电路 在图1 a 所示电路中 当输出电压为正时 BG1管工作 BG2管截止 输出电压为负时 BG1管截止 BC2管工作 二极管D1
  • C、C++、C#、python、java编程—文件读取

    C资料 菜鸟教程 C语言中文网 C community C 资料 菜鸟教程 cplusplus C community C 资料 菜鸟教程 microsoftC 文档 python资料 菜鸟教程 python标准库 Java资料 菜鸟教程
  • Multisim14.0安装教程

    2 安装步骤 解压 打开 Multisim14 0 鼠标右击 NI Circuit Design Suite 14 0 exe 选择 以管理员身份运行 点击确定 选择文件的解压路径 最好不解压在C盘 安装完成删掉即可 然后点击 Unzip
  • 华为OD机试2023(JS,C++,JAVA,PYTHON)-服务器能耗统计

    本篇题解 服务器耗能 题目描述 服务器有三种运行状态 空载 单任务 多任务 每个 时间片 的能耗的分别为 1 1 1 3 3 3 4 4 4 每个任务由起始时间片和结束时间片定义运行时间 如果一个时间片只有一个任务需要执行 则服务器处于单任
  • 微信小程序的常见的面试题(总结)

    1 微信小程序有几个文件 WXML WeiXin Markup Language 是框架设计的一套标签语言 结合基础组件 事件系统 可以构建出页面的结构 内部主要是微信自己定义的一套组件 WXSS WeiXin Style Sheets 是
  • Qt实现IP输入框(模仿Windows系统中的IP输入框)

    本文章所用的代码整理自Qt实现IP输入框 qt中ip地址输入框 GreenArrowMan的博客 CSDN博客 感谢原作者分享 本代码在上述作者代码基础上做了如下修改 1 屏蔽中文输入法 2 修复原作者代码中输入框四周的黑色边线无法正常显示
  • 【安装问题】python安装weditor出现报错总结

    python安装weditor出现报错总结 问题描述 主要原因是公司使用的python2版本过老 由于不能随意升级python版本 只能在python2的基础上解决办法 有很多地方需要更新 总结命令如下 基本上试过一遍 问题就可以解决了 解
  • 深度学习源码小项目汇总-代码全

    demo仓库和视频演示 到此一游7758258的个人空间 哔哩哔哩 bilibili 卷积网路CNN分类的模型一般使用包括alexnet DenseNet DLA GoogleNet Mobilenet ResNet ResNeXt Shu
  • 财报解读:毛利持续改善,金山云正在“弯道超车”?

    一季度 云巨头们的表现持续稳健 依旧稳坐前排 而作为中小云代表的金山云也在5月23日发布了2023年一季度财报 盈利能力持续改善成为通篇最亮眼的一笔 随着AI大模型打开了新的 潘多拉魔盒 云市场也在发生着巨变 但AI能否成为云厂商打开盈利大
  • JavaScript实现经典消方块游戏

    操作方式 在游戏区域中任意位置滑动手势 点击屏幕下方的按钮 键盘WASD和 都可以操作 游戏动作 操作 方块向左移动 左划 按下蓝色键 左一 A 方块向右移动 右划 按下橙色键 右一 D 强制方块下落 下划 按下粉色键 左二 S 改变方块方