【JavaScript】飞机大战简单网页版(源码下载)

news2024/11/18 14:27:19

文章目录

    • 一、效果演示
      • 设计思路
    • 二、鼠标版飞机大战代码展示
      • 1.HTML结构代码
      • 2.CSS样式代码
      • 3.JavaScript代码
        • js.js文件
        • plane.js文件
    • 三、键盘版飞机大战代码展示
      • 1.HTML结构代码
      • 2.CSS样式代码
      • 3.JavaScript代码
    • 四、代码资源分享

一、效果演示

利用html,css,js制作出飞机大战的简易版
需要代码的小伙伴可以在文章末尾资源自行下载,下载打开运行在浏览器即可游戏,本篇资源分享分为两个版本,一个是键盘版本(awsd移动和k攻击),一个是鼠标移动版

设计思路

  1. 在游戏进行界面中,通过鼠标操控自己方飞机(仅一架),在初始化时就进行无限制的匀速发射子弹。

  2. 在游戏进行界面中,左上方有得到的分数显示,敌方飞机有三种类型(小,中,大),他们的形状,大小,击落的分数各不同,以合适的速度控制它们的数量,以及运动的速度。

  3. 在进行游戏的过程中点击鼠标左键会进入游戏暂停界面,有重新开始,回到主页,继续三个选项。当游戏结束时,会弹出游戏分数框,有继续按钮,点击回到主页。

请添加图片描述

二、鼠标版飞机大战代码展示

1.HTML结构代码

<body>
    <div id="plane">
        <span>分数:<strong style="font-weight: normal;">0</strong></span>
    </div>
    <script type="text/javascript" src="js.js"></script>
    <script type="text/javascript" src="plane.js"></script>
</body>

2.CSS样式代码

<style type="text/css">
        *{
            padding:0px;
            margin:0px;
        }
        #plane{
            width: 320px;
            height: 568px;
            background: url(img/background.png);
            position: relative;
            margin:50px auto 0;
            cursor: none;
            overflow: hidden;
        }
        #plane span{
            position: absolute;
            right:10px;
            top:5px;
        }
    </style>

3.JavaScript代码

js.js文件

//缓冲运动
function getStyle(obj, attr) {
    if (obj.currentStyle) {
        return obj.currentStyle[attr];
    } else {
        return getComputedStyle(obj)[attr];
    }
}


function startMove(obj, json, fn) {
    var cur = 0;
    var timer = null;
    var speed = null;
    clearInterval(obj.timer)
    obj.timer = setInterval(function() {
        var bstop = true;
        for (var attr in json) {
            if (attr == 'opacity') {//求初始值
                cur = Math.round(getStyle(obj, attr) * 100);
            } else {
                cur = parseInt(getStyle(obj, attr));
            }
            speed = (json[attr] - cur) / 8;
            speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed); 
            if (cur != json[attr]) {
                bstop = false;
                if (attr == 'opacity') {
                    obj.style[attr] = (cur + speed) / 100;
                    obj.style.filter = 'alpha(opacity=' + (cur + speed) + ')';
                } else {
                    obj.style[attr] = cur + speed + 'px';
                }
            }
        }
        if (bstop) {
            clearInterval(obj.timer);
            fn && fn();
        }
    }, 30);
}



//通过类名获取元素
function getClass(oClass, oParent) {
    var oP = oParent || document;
    var arr = [];
    var aEle = oP.getElementsByTagName('*');
    var reg = new RegExp('\\b' + oClass + '\\b');
    for (var i = 0; i < aEle.length; i++) {
        if (reg.test(aEle[i].className)) {
            arr.push(aEle[i]);
        }
    }
    return arr;
}


//取任意的随机数,范围是min-max之间
function getrandom(min,max){
    return Math.floor(Math.random()*(max-min+1))+min;
}

plane.js文件

//我方飞机构造函数
var planeBox = document.getElementById('plane');
var planescore = document.getElementsByTagName('strong')[0];
var zscore = 0;


function Myplane(w, h, imgsrc, boomsrc) {
    this.w = w;
    this.h = h;
    this.imgsrc = imgsrc;
    this.boomsrc = boomsrc;
    this.createMyplane();
}


//创建我方飞机
Myplane.prototype.createMyplane = function() {
    this.plane = document.createElement('img');
    this.plane.src = this.imgsrc;
    this.plane.style.cssText = 'width:' + this.w + 'px;height:' + this.h + 'px;position:absolute;left:' + (planeBox.offsetWidth - this.w) / 2 + 'px;top:' + (planeBox.offsetHeight - this.h) + 'px;';
    planeBox.appendChild(this.plane);
    this.move();
    this.shoot();
};


//我方飞机移动
Myplane.prototype.move = function() {
    var that = this;
    document.onmousemove = function(ev) {
        var ev = ev || window.event;
        that.oLeft = ev.clientX - plane.offsetLeft - that.w / 2;
        that.oTop = ev.clientY - plane.offsetTop - that.h / 2;
        if (that.oLeft < 0) {
            that.oLeft = 0;
        } else if (that.oLeft >= plane.offsetWidth - that.w) {
            that.oLeft = plane.offsetWidth - that.w
        }


        if (that.oTop < 0) {
            that.oTop = 0;
        } else if (that.oTop >= plane.offsetHeight - that.h) {
            that.oTop = plane.offsetHeight - that.h;
        }


        that.plane.style.left = that.oLeft + 'px';
        that.plane.style.top = that.oTop + 'px';
        return false;
    }
};
//我方飞机发射子弹
Myplane.prototype.shoot = function() {
    var that = this;
    document.onmousedown = function(ev) {
        var ev = ev || window.event;
        if (ev.which == 1) {
            bulletshoot();
            that.timer = setInterval(bulletshoot, 200);


            function bulletshoot() {
                var bullet = new Bullet(that.plane.offsetLeft + that.w / 2 - 3, that.plane.offsetTop - 14, 6, 14, 'img/bullet.png');
            }
        }
        return false;
    }
    document.onmouseup = function(ev) {
        var ev = ev || window.event;
        if (ev.which == 1) {
            clearInterval(that.timer);
        }
    }
    document.oncontextmenu = function() {
        return false;
    }
};




//子弹的构造函数
function Bullet(x, y, w, h, imgsrc) {
    this.x = x; //位置
    this.y = y;
    this.w = w; //尺寸
    this.h = h;
    this.imgsrc = imgsrc;
    this.createBullet();
}


//创建子弹
Bullet.prototype.createBullet = function() {
    this.bullet = document.createElement('img');
    this.bullet.src = this.imgsrc;
    this.bullet.style.cssText = 'width:' + this.w + 'px;height:' + this.h + 'px;position:absolute;left:' + this.x + 'px;top:' + this.y + 'px;';
    planeBox.appendChild(this.bullet);
    this.move();
}


//子弹移动
Bullet.prototype.move = function() {
    var that = this;
    this.timer = setInterval(function() {
        that.y -= 5;
        if (that.y <= -that.h) {
            clearInterval(that.timer);
            planeBox.removeChild(that.bullet);
        }
        that.bullet.style.top = that.y + 'px';
        that.hit();
    }, 20);
};


Bullet.prototype.hit = function() {
    var allEnemy = document.getElementsByClassName('planeEnemy');
    for (var i = 0; i < allEnemy.length; i++) {
        if ((this.x + this.w) >= allEnemy[i].offsetLeft && this.x <= (allEnemy[i].offsetLeft + allEnemy[i].offsetWidth) && this.y <= (allEnemy[i].offsetTop + allEnemy[i].offsetHeight)) {
            clearInterval(this.timer);
            try{


            planeBox.removeChild(this.bullet);
            }catch(e){


            }
            allEnemy[i].hp--;
            allEnemy[i].checkhp();
        }
    }
};



//敌方飞机的构造函数
function Enemyplane(x, y, w, h, imgsrc, boomsrc, speed, hp, score) {
    this.x = x; //位置
    this.y = y;
    this.w = w; //尺寸
    this.h = h;
    this.imgsrc = imgsrc;
    this.boomsrc = boomsrc;
    this.speed = speed;
    this.hp = hp;
    this.score = score;
    this.createEnemy();
}


//创建敌机
Enemyplane.prototype.createEnemy = function() {
    var that = this;
    this.enemy = document.createElement('img');
    this.enemy.src = this.imgsrc;
    this.enemy.className = 'planeEnemy'; //通过设置类名,方便后面获取
    this.enemy.style.cssText = 'width:' + this.w + 'px;height:' + this.h + 'px;position:absolute;left:' + this.x + 'px;top:' + this.y + 'px;';
    planeBox.appendChild(this.enemy);
    this.enemy.hp = this.hp; //变化的
    this.enemy.score = this.score; //变化的
    this.enemy.checkhp = function() { //this==this.enemy 
        if (this.hp <= 0) {
            clearInterval(this.timer);
            this.className = '';
            this.src = that.boomsrc;
            setTimeout(function() {
                planeBox.removeChild(that.enemy);
            }, 1000);
            zscore += this.score
            planescore.innerHTML = zscore;
        }
    }
    this.move();
}


Enemyplane.prototype.move = function() {
    var that = this;
    this.enemy.timer = setInterval(function() {
        that.y += that.speed;
        if (that.y >= planeBox.offsetHeight) {
            clearInterval(that.enemy.timer);
            planeBox.removeChild(that.enemy);
        }
        that.enemy.style.top = that.y + 'px';
        that.enemyhit();
    }, 50);
}



Enemyplane.prototype.enemyhit = function() {
    if ((this.y + this.h) >= myplane.oTop && this.y <= (myplane.oTop + myplane.h) && (this.x + this.w) > myplane.oLeft && this.x <= (myplane.oLeft + myplane.w)) {
        var allEnemy = document.getElementsByClassName('planeEnemy');
        for (var i = 0; i < allEnemy.length; i++) {
            clearInterval(allEnemy[i].timer);
        }
        clearInterval(timer);
        document.onmousedown = null;
        document.onmousemove = null;
        myplane.plane.src = myplane.boomsrc;
        setTimeout(function() {
            alert('game over!!');
            window.location.reload(); //重刷新
        }, 3000);
    }
}


var myplane = new Myplane(66, 80, 'img/myplane.gif', 'img/myplaneBoom.gif');


for (var i = 0; i < getrandom(1, 2); i++) { //随机创建各类飞机
    var timer = setInterval(function() {
        var num = getrandom(1, 20); //1-15 小飞机  16-20 中飞机  20打飞机
        if (num >= 1 && num < 15) {
            var enemy = new Enemyplane(getrandom(0, planeBox.offsetWidth - 34), -24, 34, 24, 'img/smallplane.png', 'img/smallplaneboom.gif', getrandom(3, 5), 1, 1);
        } else if (num >= 15 && num < 20) {
            var enemy = new Enemyplane(getrandom(0, planeBox.offsetWidth - 46), -60, 46, 60, 'img/midplane.png', 'img/midplaneboom.gif', getrandom(2, 4), 3, 5);
        } else if (num == 20) {
            var enemy = new Enemyplane(getrandom(0, planeBox.offsetWidth - 110), -164, 110, 164, 'img/bigplane.png', 'img/bigplaneboom.gif', getrandom(1, 2), 10, 10);
        }
    }, 1000)
}

三、键盘版飞机大战代码展示

1.HTML结构代码

<body>
    <div class="gamebox">
    	<span>分数:<em>0</em></span>
    </div>
    <script type="text/javascript" src="plane.js"></script>
</body>

2.CSS样式代码

 <style type="text/css">
    * {
        padding: 0px;
        margin: 0px;    
    }
    .gamebox{
    	width: 320px;
    	height:568px;
    	background: url(img/background.png) repeat-y;
    	margin:20px auto;
    	position: relative;
    	cursor: none;
    	overflow: hidden;
    }
    .gamebox span{
    	position: absolute;
    	right:10px;
    	top:10px;
    }
    .gamebox span em{
    	font-style: normal;
    }
    </style>

3.JavaScript代码

;
(function() {
    var gamebox = document.querySelector('.gamebox');
    var oEm = document.querySelector('em');
    var zscore = 0;
    //1.让背景运动起来
    var bgposition = 0;
    var bgtimer = setInterval(function() {
        bgposition += 2;
        gamebox.style.backgroundPosition = '0 ' + bgposition + 'px';
    }, 30);



    //2.我方飞机的构造函数
    function Myplane(w, h, x, y, imgurl, boomurl) { //w,h宽高 x,y位置  imgurl和boomurl我方飞机的图片路径
        this.w = w;
        this.h = h;
        this.x = x;
        this.y = y;
        this.imgurl = imgurl;
        this.boomurl = boomurl;
        this.createmyplane()
    }
    //2.1创建我方飞机
    Myplane.prototype.createmyplane = function() {
        this.myplaneimg = document.createElement('img');
        this.myplaneimg.src = this.imgurl;
        this.myplaneimg.style.cssText = `width:${this.w}px;height:${this.h}px;position:absolute;left:${this.x}px;top:${this.y}px;`;
        gamebox.appendChild(this.myplaneimg);
        //飞机创建完成,执行运动和发射子弹
        this.myplanemove();
        this.myplaneshoot();
    }
    //2.2键盘控制我方飞机移动
    Myplane.prototype.myplanemove = function() {
        var that = this;
        //方向定时器
        var uptimer = null,
            downtimer = null,
            lefttimer = null,
            righttimer = null;
        var uplock = true,
            downlock = true,
            leftlock = true,
            rightlock = true;
        document.addEventListener('keydown', movekey, false); //movekey:事件处理函数
        function movekey(ev) { //W:87 A:65 S:83 D:68  K:75
            var ev = ev || window.event;
            switch (ev.keyCode) {
                case 87:
                    moveup(); // 上
                    break;
                case 83:
                    movedown(); // 下
                    break;
                case 65:
                    moveleft(); // 左
                    break;
                case 68:
                    moveright(); // 右
                    break;
            }


            function moveup() {
                if (uplock) {
                    uplock = false;
                    clearInterval(downtimer);
                    uptimer = setInterval(function() {
                        that.y -= 4;
                        if (that.y <= 0) {
                            that.y = 0;
                        }
                        that.myplaneimg.style.top = that.y + 'px';
                    }, 30);
                }


            }


            function movedown() {
                if (downlock) {
                    downlock = false;
                    clearInterval(uptimer);
                    downtimer = setInterval(function() {
                        that.y += 4;
                        if (that.y >= gamebox.offsetHeight - that.h) {
                            that.y = gamebox.offsetHeight - that.h;
                        }
                        that.myplaneimg.style.top = that.y + 'px';
                    }, 30);
                }


            }


            function moveleft() {
                if (leftlock) {
                    leftlock = false;
                    clearInterval(righttimer);
                    lefttimer = setInterval(function() {
                        that.x -= 4;
                        if (that.x <= 0) {
                            that.x = 0;
                        }
                        that.myplaneimg.style.left = that.x + 'px';
                    }, 30);
                }


            }


            function moveright() {
                if (rightlock) {
                    rightlock = false;
                    clearInterval(lefttimer);
                    righttimer = setInterval(function() {
                        that.x += 4;
                        if (that.x >= gamebox.offsetWidth - that.w) {
                            that.x = gamebox.offsetWidth - that.w;
                        }
                        that.myplaneimg.style.left = that.x + 'px';
                    }, 30);
                }


            }


        }


        document.addEventListener('keyup', function(ev) {
            var ev = ev || window.event;
            if (ev.keyCode == 87) {
                clearInterval(uptimer);
                uplock=true;
            }


            if (ev.keyCode == 83) {
                clearInterval(downtimer);
                downlock=true;
            }


            if (ev.keyCode == 65) {
                clearInterval(lefttimer);
                leftlock=true;
            }


            if (ev.keyCode == 68) {
                clearInterval(righttimer);
                rightlock=true;
            }
        }, false);
    }


    //2.3我方飞机发射子弹
    Myplane.prototype.myplaneshoot = function() {
        var that = this;
        var shoottimer = null;
        var shootlock = true;
        document.addEventListener('keydown', shootbullet, false);


        function shootbullet(ev) {
            var ev = ev || window.event;
            if (ev.keyCode == 75) {
                if (shootlock) {
                    shootlock = false;


                    function shoot() {
                        new Bullet(6, 14, that.x + that.w / 2 - 3, that.y - 14, 'img/bullet.png');
                    }
                    shoot();
                    shoottimer = setInterval(shoot, 200);
                }
            }
        }
        document.addEventListener('keyup', function(ev) {
            var ev = ev || window.event;
            if (ev.keyCode == 75) {
                clearInterval(shoottimer);
                shootlock = true;
            }
        }, false);
    }



    //3.子弹的构造函数
    function Bullet(w, h, x, y, imgurl) { //w,h宽高 x,y位置  imgurl图片路径
        this.w = w;
        this.h = h;
        this.x = x;
        this.y = y;
        this.imgurl = imgurl;
        //创建子弹
        this.createbullet();
    }


    //3.1创建子弹
    Bullet.prototype.createbullet = function() {
        this.bulletimg = document.createElement('img');
        this.bulletimg.src = this.imgurl;
        this.bulletimg.style.cssText = `width:${this.w}px;height:${this.h}px;position:absolute;left:${this.x}px;top:${this.y}px;`;
        gamebox.appendChild(this.bulletimg);
        //子弹创建完成,执行运动。
        this.bulletmove();
    }
    //3.2子弹运动
    Bullet.prototype.bulletmove = function() {
        var that = this;
        this.timer = setInterval(function() {
            that.y -= 4;
            if (that.y <= -that.h) { //让子弹消失
                clearInterval(that.timer);
                gamebox.removeChild(that.bulletimg);
            }
            that.bulletimg.style.top = that.y + 'px';
            that.bullethit();
        }, 30)


    }
    Bullet.prototype.bullethit = function() {
        var enemys = document.querySelectorAll('.enemy');
        for (var i = 0; i < enemys.length; i++) {
            if (this.x + this.w >= enemys[i].offsetLeft && this.x <= enemys[i].offsetLeft + enemys[i].offsetWidth && this.y + this.h >= enemys[i].offsetTop && this.y <= enemys[i].offsetTop + enemys[i].offsetHeight) {
                clearInterval(this.timer);
                try {
                    gamebox.removeChild(this.bulletimg);
                } catch (e) {
                    return;
                }


                //血量减1
                enemys[i].blood--;
                //监听敌机的血量(给敌机添加方法)
                enemys[i].checkblood();
            }
        }


    }
    //4.敌机的构造函数
    function Enemy(w, h, x, y, imgurl, boomurl, blood, score, speed) {
        this.w = w;
        this.h = h;
        this.x = x;
        this.y = y;
        this.imgurl = imgurl;
        this.boomurl = boomurl;
        this.blood = blood;
        this.score = score;
        this.speed = speed;
        this.createenemy();
    }


    //4.1创建敌机图片
    Enemy.prototype.createenemy = function() {
        var that = this;
        this.enemyimg = document.createElement('img');
        this.enemyimg.src = this.imgurl;
        this.enemyimg.style.cssText = `width:${this.w}px;height:${this.h}px;position:absolute;left:${this.x}px;top:${this.y}px;`;
        gamebox.appendChild(this.enemyimg);


        this.enemyimg.className = 'enemy'; //给每一架创建的敌机添加类
        this.enemyimg.score = this.score; //给每一架创建的敌机添加分数
        this.enemyimg.blood = this.blood; //给每一架创建的敌机添加自定义的属性--血量
        this.enemyimg.checkblood = function() {
            //this==>this.enemyimg
            if (this.blood <= 0) { //敌机消失爆炸。
                this.className = ''; //去掉类名。
                this.src = that.boomurl;
                clearInterval(that.enemyimg.timer);
                setTimeout(function() {
                    gamebox.removeChild(that.enemyimg);
                }, 300);
                zscore += this.score;
                oEm.innerHTML = zscore;
            }
        }
        //子弹创建完成,执行运动。
        this.enemymove();
    }
    //4.2敌机运动
    Enemy.prototype.enemymove = function() {
        var that = this;
        this.enemyimg.timer = setInterval(function() {
            that.y += that.speed;
            if (that.y >= gamebox.offsetHeight) {
                clearInterval(that.enemyimg.timer);
                gamebox.removeChild(that.enemyimg);
            }
            that.enemyimg.style.top = that.y + 'px';
            that.enemyhit();
        }, 30);
    }


    //4.3敌机碰撞我方飞机
    Enemy.prototype.enemyhit = function() {
        if (!(this.x + this.w < ourplane.x || this.x > ourplane.x + ourplane.w || this.y + this.h < ourplane.y || this.y > ourplane.y + ourplane.h)) {
            var enemys=document.querySelectorAll('.enemy');
            for (var i = 0; i < enemys.length; i++) {
                clearInterval(enemys[i].timer);
            }
            clearInterval(enemytimer);
            clearInterval(bgtimer);
            ourplane.myplaneimg.src = ourplane.boomurl;
            setTimeout(function() {
                gamebox.removeChild(ourplane.myplaneimg);
                alert('game over!!');
                location.reload();
            }, 300)
        }
    }


    var enemytimer = setInterval(function() {
        for (var i = 0; i < ranNum(1, 3); i++) {
            var num = ranNum(1, 20); //1-20
            if (num < 15) { //小飞机
                new Enemy(34, 24, ranNum(0, gamebox.offsetWidth - 34), -24, 'img/smallplane.png', 'img/smallplaneboom.gif', 1, 1, ranNum(2, 4));
            } else if (num >= 15 && num < 20) {
                new Enemy(46, 60, ranNum(0, gamebox.offsetWidth - 46), -60, 'img/midplane.png', 'img/midplaneboom.gif', 3, 5, ranNum(1, 3));
            } else if (num == 20) {
                new Enemy(110, 164, ranNum(0, gamebox.offsetWidth - 110), -164, 'img/bigplane.png', 'img/bigplaneboom.gif', 10, 10, 1);
            }
        }
    }, 3000);


    function ranNum(min, max) {
        return Math.round(Math.random() * (max - min)) + min;
    }
    //实例化我方飞机
    var ourplane = new Myplane(66, 80, (gamebox.offsetWidth - 66) / 2, gamebox.offsetHeight - 80, 'img/myplane.gif', 'img/myplaneBoom.gif');
})();

四、代码资源分享

💡点击链接下载飞机大战i资源https://gitee.com/huang_weifu/JavaScript_demo.git

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/125243.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

qt QCustomplot 用QCPItemStraightLine画参考线,阈值线,水平线

想要在两个坐标系下都画上如下参考线(阈值线&#xff0c;或者 水平线)&#xff0c; 这个参考线随着坐标轴的拖拽能够一直显示 我们找到了QCPItemStraightLine&#xff0c;该类能够画一条无限延伸的直线&#xff0c;通过下面的代码能够实现在A坐标系画一条水平线&#xff0c;但不…

[CF-EDU]Segment Tree - part 1 - Step 1 - Practice

练习名称&#xff1a;ITMO Academy: pilot course Segment Tree 练习链接&#xff1a;Segment Tree, part 1, Step1, Practice cf官方的线段树专题练习 A. Segment Tree for the Sum 单点修改&#xff0c;区间和查询 #include <bits/stdc.h> #define lson (u <&l…

P1825 [USACO11OPEN]Corn Maze S

题目描述 This past fall, Farmer John took the cows to visit a corn maze. But this wasnt just any corn maze: it featured several gravity-powered teleporter slides, which cause cows to teleport instantly from one point in the maze to another. The slides work…

Docker安装镜像,并运行成为容器

1.Docker作用 一个项目中&#xff0c;部署时需要依赖于node.js、Redis、RabbitMQ、MySQL等&#xff0c;这些服务部署时所需要的函数库、依赖项各不相同&#xff0c;甚至会有冲突。给部署带来了极大的困难。 而Docker确巧妙的解决了这些问题, Docker为了解决依赖的兼容问题的…

关于两种单菌种发酵的豆瓣酱代谢组学方面差异研究

生活离不开柴米油盐酱醋茶&#xff0c;其中酱油是中国传统的调味品&#xff0c;主要是由大豆经过发酵酿造而成。酱油由酱演变而来&#xff0c;早在三千多年前&#xff0c;中国就有制作酱的记载了。 本期百趣代谢组学文献分享为大家分享的文献是百趣生物协助客户发表的关于两种…

Git cherry-pick

Git cherry-pick 当有多个分支&#xff0c;想将一个分支 A 的提交合并到另一个分支 B 一&#xff1a;将分支A的所有提交合并到分支B&#xff0c;执行合并即可 二&#xff1a;将分支A 的某一次提交合并到分支 B&#xff0c;需要使用 git cherry-pick commit 命令 如下图&#…

随机森林-sklearn

随机森林 1.概述 1.1 集成算法概述 本身并不是一个单独的机器学习算法&#xff0c;而是通过在数据上构建多个模型&#xff0c;集成所有模型的建模结果。以此来获得最好的结果。 集成算法的目标&#xff1a; 集成算法会考虑多个评估器的建模结果&#xff0c;汇总之后得到一个…

物联网低功耗蓝牙核心配置技术: 赋能智能家居和智能工业场景

蓝牙我们都不陌生&#xff0c;早已成为深入我们生活的一项科技。不过&#xff0c;我们所知所用的还只是蓝牙的一部分。而蓝牙目前作为物联网中的一项重要通信技术&#xff0c;其应用还远远不止这些&#xff0c;今天就为大家讲讲蓝牙技术中的低功耗技术的应用及分类。 蓝牙低功耗…

原神私服搭建教程 (最新版)

搭建教程 1.准备阶段 1.请先确保电脑内有这些安装环境&#xff0c;否则私服无法运行&#xff01;&#xff01;&#xff01; MongoDB Python3.8 java17 mitmproxy 没有请在群文件下载安装环境&#xff0c;安装即可。特别强调&#xff1a;java17直接放在C:\Program Files目录下即…

初识Kubernetes:(4)Kubernetes实战入门

初识Kubernetes&#xff1a;&#xff08;4&#xff09;Kubernetes实战入门1 前言2 Namespace2.1 概述2.2 应用示例3 Pod3.1 概述3.2 语法及应用示例1 前言 介绍如何在kubernetes集群中部署一个Nginx服务&#xff0c;并且能够对其访问。 2 Namespace 2.1 概述 Namespace是ku…

写给Java程序员的GRPC入门系列(2)

点击上方GRPC专栏看完整系列 文章目录Abstract前置依赖本文初始状态编写protobuffer文件生成代码下一步Abstract 网上有很多GRPC的例子&#xff0c;但是却没有能够写给普通Java开发人员手把手入门少走弯路的教程。 本教程保证按照步骤一步步来你就可以完成GRPC从0到1的构建。 …

模型驱动PDR、数据驱动PDR实验效果对比

本学期的室内导航位置服务课程结束了&#xff0c;最后有一个结课作业做了一些工作&#xff0c;在这里分享给大家&#xff0c;同时也是自己的一个记录。 主要内容包括以下四个方面&#xff1a; 模型驱动PDR数据驱动PDR实验效果对比模型驱动PDR测试效果数据驱动PDR-RoNIN官方预训…

JSP ssh相亲网站系统myeclipse开发mysql数据库MVC模式java编程计算机网页设计

一、源码特点 JSP ssh相亲系统是一套完善的web设计系统&#xff08;系统采用ssh框架进行设计开发&#xff09;&#xff0c;对理解JSP java编程开发语言有帮助&#xff0c;系统具有完整的源代码和数据库&#xff0c;系统主要采用B/S模式开发 。开发环境为TOMCAT7.0,Myeclip…

MergeTree原理之存储

我们都知道在MergeTree中数据是按列存储的&#xff0c;但是具体到存储的细节、以及如何工作的&#xff0c;都存在很多疑问。数据存储&#xff0c;就好比一本书中的文字&#xff0c;在排版时&#xff0c;绝不会密密麻麻地把文字堆满&#xff0c;这样会导致难以阅读。更为优雅的做…

Git学习:各阶段回退方法

文章目录一、问题背景二、解决方式1. 回退情况1&#xff1a;文件在工作区进行回退2. 回退情况2&#xff1a;文件在暂存区进行回退3. 回退情况3&#xff1a;文件在本地仓库进行回退4. 回退情况4&#xff1a;文件已经在远程仓库中一、问题背景 Git 是分布式的软件管理系统。在把…

代码随想录拓展day4 205. 同构字符串;1002. 查找常用字符;925.长按键入;844.比较含退格的字符串

代码随想录拓展day4 205. 同构字符串&#xff1b;1002. 查找常用字符&#xff1b;925.长按键入&#xff1b;844.比较含退格的字符串 哈希表和字符串的一些应用&#xff0c;放到一起了。 同构字符串 https://leetcode.cn/problems/isomorphic-strings/description/ 刚开始以…

spring boot:集成支付宝(沙箱环境)(spring boot 2.4.0 / wap/h5方式 )

一&#xff0c;配置支付宝沙箱环境: 1,沙箱的地址: 登录 - 支付宝 也可以登录后&#xff0c;从控制台点击 研发服务 进入 2&#xff0c;下载开发助手:并生成密钥 从这个页面&#xff0c;按自己所在的平台下载&#xff0c; 当前支持 windows,macos 开发助手简介 &#xf…

自定义Tango Control设备服务在Ubuntu中的测试

文章目录环境create a device classcompile the device classregister the devicestart the deviceexplore the device故障问题解决参考继续上一篇&#xff1a;https://blog.csdn.net/woshigaowei5146/article/details/128443892?spm1001.2014.3001.5501 环境 虚拟机&#xf…

布隆过滤器 以及缓存穿透问题

1. 前言 今天从客观的角度来分析下&#xff0c;什么是缓存穿透&#xff0c;什么是布隆过滤器&#xff0c;布隆过滤器是如何解决缓存穿透的。 2. 适合人群 对布隆过滤器不熟悉的人对Redis 缓存穿透不熟悉的人 3. 开始 3.1 什么是缓存穿透 其实通过上图我们可以知道&#xff0…

(七)Filter

Filter 表示过滤器&#xff0c;是JavaWeb 三大组件(Servlet、Filter、Listener)之一。过滤器可以把对资源的请求拦截下来&#xff0c;从而实现一些特殊的功能。 过滤器一般完成一些通用的操作&#xff0c;比如&#xff1a;权限控制、统一编码处理、敏感字符处理等等..一、Filte…