当前位置: 首页 > news >正文

用java编写飞机大战

游戏界面使用JFrame和JPanel构建。背景图通过BG类绘制。英雄机和敌机在界面上显示并移动。子弹从英雄机发射并在屏幕上移动。游戏有四种状态:READY、RUNNING、PAUSE、GAMEOVER。状态通过鼠标点击进行切换:点击开始游戏(从READY变为RUNNING)。点击重新开始游戏(从GAMEOVER变为READY)。鼠标移出窗口时游戏暂停(从RUNNING变为PAUSE)。鼠标移入窗口时游戏继续(从PAUSE变为RUNNING)。开局默认玩家生命值为3,分数为0。每隔一定时间随机生成敌机(小飞机、大飞机、小飞碟)。敌机在屏幕上移动,并与英雄机进行碰撞检测。英雄机可以发射子弹。子弹在屏幕上移动,并与敌机进行碰撞检测。英雄机与敌机发生碰撞时,英雄机会损失一条生命值。子弹与敌机发生碰撞时,敌机会被摧毁,玩家的分增加。当子弹与奖励机发生碰撞时,奖励机会被摧毁,玩家随机获得两张奖励(生命值加1、双倍子弹)。在屏幕左上角显示当前的生命值和得分。生命值减少到0时,游戏进入结束状态。再次点击,重新开始游戏。

1.图片素材(百度网盘分享)

链接:https://pan.baidu.com/s/10QiTcddI_Zxw5jbn8fmOpA?pwd=huan 
提取码:huan

2.主页面world.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;public class World extends JPanel {//ImageIcon类:保存图片的路径----->读取图片
//    ImageIcon icon = new ImageIcon("images\\background.png");
//    BG bg = new BG(0,0,420,700,2);
//    Airplane airplane = new Airplane(100,200,300,620,2);
//    Bee bee = new Bee(200,100,200,700,2);BG bg = new BG();EnemyPlane [] planes;Hero hero;int index; //用来控制敌机的数量Bullet[] bullets;  //创建子弹的数组int life; //英雄机的生命值int score; //分数//定义游戏的四种状态:准备,运行,暂停,结束(常量)public static final int READY = 0;public static final int RUNNING = 1;public static final int PAUSE = 2;public static final int GAMEOVER = 3;//游戏的初始状态int state = READY;//    Airplane [] airPlanes = new Airplane[10];
//    Bigairplane [] bigAirPlanes = new Bigairplane[10];
//    Bee [] bee = new Bee[10];
//    Bom [] bom = new Bom[4];
//    Bullet [] bullets = new Bullet[3];
//    Hero [] hero =new Hero[2];//初始化方法public void init(){bg = new BG();hero = new Hero();planes = new EnemyPlane[0]; //默认一个敌机都没有bullets = new Bullet[0];  //默认一个子弹都没有index = 0; //默认从0开始life = 3; //默认3条命score = 0; //分数为0}public World() {init();//        for(int i=0;i<planes.length;i++){
//            if(i%2==0){
//                planes[i]=new Airplane();
//            }
//            else if(i%5==0 && i%2!=0){
//                planes[i] = new Bee();
//            }
//            else {
//                planes[i] = new Bigairplane();
//            }
//        }
//        for(int i =0;i<airPlanes.length;i++){
//            airPlanes[i] = new Airplane();
//            bigAirPlanes[i]=new BigAirPlane();
//            bee[i]=new Bee();
//            bom[i]=new Bom();
//            bullets[i]=new Bullet();
//            hero[i]=new Hero();}//生成敌机的方法public void createPlane(){if(index%16==0){int n = (int)(Math.random()*10);EnemyPlane plane;switch (n){case 9 :plane = new Bee(); //10%生成小飞碟break;case 8 :case 7 :plane = new Bigairplane(); //20%生成大飞机break;default:plane = new Airplane(); //70%生成小飞机}//将敌机存入数组中之前,要先对数组进行扩容处理planes = Arrays.copyOf(planes,planes.length+1);//将生存的敌机放入数组的最后一个位置planes[planes.length-1] = plane;}}//        for(int i =0;i<bigAirPlanes.length;i++){
//            bigAirPlanes[i]=new Bigairplane();
//       }
//    }//绘制图片printing@Overridepublic void paint(Graphics g) { //paint挂载到当前类,当前类实例化(创建对象)时自动调用
//      super.paint(g);
//      icon.paintIcon(this,g,0,y1++); //绘制背景,默认第一个绘制
//        bg.icon.paintIcon(this,g,(int)bg.x,(int)bg.y);
//      bg.move();
//        airplane.icon.paintIcon(this,g,(int)airplane.x,(int)airplane.y);
//        bee.icon.paintIcon(this,g,(int)bee.x,(int)bee.y);bg.painting(g);hero.painting(g);for(int i=0;i<planes.length;i++){planes[i].painting(g);}for(int i=0;i<bullets.length;i++){bullets[i].painting(g);}g.setColor(new Color(255,255,255));//设置字体g.setFont(new Font("微软雅黑",Font.BOLD,20));g.drawString("生命值"+life,20,20);g.drawString("分数"+score,20,40);if(state==READY){Images.start.paintIcon(this,g,0,0);}if(state==PAUSE){Images.pause.paintIcon(this,g,0,0);}if(state==GAMEOVER){Images.gameover.paintIcon(this,g,0,0);}//            for(int i =0;i<airPlanes.length;i++){
//                airPlanes[i].painting(g);
//            bigAirPlanes[i].painting(g);
//            bee[i].painting(g);
//            bom[i].painting(g);
//            bullets[i].painting(g);
//            hero[i].painting(g);
//            }
//            for(int i =0;i<bigAirPlanes.length;i++){
//                bigAirPlanes[i].painting(g);
//            }repaint();//刷新窗口}public static void main(String[] args) {//1.显示画框(外层):JFrameJFrame jf = new JFrame();//2.显示面板:JpanelWorld jp =new World();//3.将面板放入画框中:jf.add(jp);//对窗口进行设置jf.setTitle("我的窗口");//设置标题jf.setSize(436,700); //设置窗口大小jf.setLocationRelativeTo(null); //居中显示jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //设置关闭窗口后自动结束程序//4.显示窗口jf.setVisible(true);jp.action();}//唤醒定时器的方法public void action(){java.util.Timer timer = new Timer();MyTesk mt = new MyTesk();timer.schedule(mt,1000,1000/50);this.addMouseListener(new MouseAdapter() {//监听鼠标点击@Overridepublic void mouseClicked(MouseEvent e) {if(state==READY){state=RUNNING;}if(state==GAMEOVER){state=READY;init();}}//鼠标移除@Overridepublic void mouseExited(MouseEvent e) {
//                System.out.println("鼠标移出");if(state==RUNNING){state=PAUSE;}}//鼠标移入@Overridepublic void mouseEntered(MouseEvent e) {if(state==PAUSE){state=RUNNING;}}});//匿名内部类MouseAdapter mouseAdapter = new MouseAdapter() {@Overridepublic void mouseMoved(MouseEvent e) {if(state==RUNNING){int x = e.getX();int y = e.getY();hero.move(x,y);}}};//安装监听器this.addMouseMotionListener(mouseAdapter);}public void createBullet(){if(!hero.isLiving()){ //英雄机死亡不发射子弹return;}if(index%17==0){Bullet[] bullets1 = hero.double_fire();//俩个数组的合并Bullet[] arr = Arrays.copyOf(bullets,bullets.length+bullets1.length);System.arraycopy(bullets1,0,arr,bullets.length,bullets1.length);bullets = arr;
//            Bullet bullet =hero.fire();  //英雄机调用fire方法生成子弹
//            //将子弹放入数组中
//            bullets = Arrays.copyOf(bullets,bullets.length+1); //子弹扩容
//            bullets[bullets.length-1] = bullet;}}//加分的方法public void addScore(FlyingObjesct plane){if(plane.isDead()){if(plane instanceof Enemy){Enemy enemy = (Enemy) plane; //需要做一个强制转化score += enemy.getScore();}if(plane instanceof Aword){Aword aword = (Aword) plane;int  type =aword.getAword();if(type == Aword.DOUBLE_FIRE){hero.getdouble_fire();}if(type == Aword.LIFE){life++;}}}}//检测敌机与英雄机的碰撞public void hero_hit(){if(hero.isLiving()){for(int i=0;i<planes.length;i++){if(!planes[i].isLiving()){continue;}if(hero.bong(planes[i])){hero.goDead();planes[i].goDead();break;}}}else if(hero.isWait()){ //僵尸状态if(life>1){//重新开始hero = new Hero();//清屏for(int i=0;i<planes.length;i++){planes[i].goDead();}life--;}else{life--;state=GAMEOVER;}}}//检测每个敌机与子弹的碰撞情况public void hit(){for(int i=0;i<bullets.length;i++){Bullet bullet = bullets[i]; //拿出每一颗子弹if(!bullet.isLiving()){continue;}for(int j=0;j<planes.length;j++){FlyingObjesct p = planes[j];if(!p.isLiving()){continue;}if(p.bong(bullet)){  //被击中p.attack();bullet.goDead();addScore(p);}}}}//清理爆炸的飞机public void clean(){//清除飞机EnemyPlane[] living = new EnemyPlane[planes.length];int index = 0;for(int i=0;i<planes.length;i++){  //遍历敌机数组if(planes[i].isWait() || planes[i].outOfBound()){  //如果是等待状态的效果就跳过continue;}living[index++] = planes[i];  //将不是等待状态的敌机存在living里面}planes = Arrays.copyOf(living,index);//清除子弹Bullet[] livingBullet = new Bullet[bullets.length];index = 0;for(int i=0;i<bullets.length;i++){if(bullets[i].isDead() || bullets[i].outOfBound()){    //如果是已经爆炸的子弹就跳过continue;}livingBullet[index++] = bullets[i];}bullets = Arrays.copyOf(livingBullet,index);}class MyTesk extends TimerTask {@Overridepublic void run() {index++;if(state == RUNNING){createPlane(); //调用生成敌机的方法createBullet(); //调用生成子弹的方法hit();//调用子弹击打的效果clean(); //调用清理敌机方法hero_hit();bg.move();for(int i =0;i<planes.length;i++){planes[i].move();}for(int i =0;i<bullets.length;i++){bullets[i].move();}}}}
}

3.小飞机类Airplane.java

package plane.gzeu;import javax.swing.*;
//飞机类
public class Airplane extends EnemyPlane implements Enemy{ // 实现接口时,要实现接口中的方法public Airplane(){this.images = Images.airplane;w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*2.5+0.7);this.icon=new ImageIcon("images\\airplane1.png");
//        this.icon = Images.airplane[0];}public Airplane(double x, double y, double w, double h,double speed) {
//        super(x, y, w, h);this.step=speed;this.icon=Images.airplane[0];}@Overridepublic int getScore() {return 10;}
}

4.大飞机类Bigairplane

package plane.gzeu;//大飞机类
public class Bigairplane extends EnemyPlane implements Enemy{public Bigairplane(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;this.icon = Images.bigairplane[0];}public Bigairplane(){this.images = Images.bigairplane; //初始化数组w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*3.5+0.7);
//        this.icon = Images.bigairplane[0];life = 4;}@Overridepublic int getScore() {return 50;}
}

5.英雄机类Hero.java

package plane.gzeu;import javax.swing.*;import static plane.gzeu.Images.bullet;public class Hero  extends EnemyPlane{public Hero(){this.images = Images.hero;x=431/2-images[0].getIconWidth()/2;y=510;w=images[0].getIconWidth();h=images[0].getIconHeight();
//        this.speed=0.2;this.icon = Images.hero[0];}public Hero(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;
//        this.icon = new ImageIcon("images\\hero1.png"); //设置了Images类直接调用类名就可以引用图片this.icon = Images.hero[0];}@Overridepublic void move() {}//接收鼠标的坐标public void move(int x,int y) {this.x= x-images[0].getIconWidth()/2;this.y = y-images[0].getIconHeight()/2;}/** 子弹的位置(在英雄机上) b.x = h.x-images[0].getIconWidth()/2; b.y=h.y* 子弹的移动:向上:b.y-=b.step;* 子弹是无限的:数序扩容* 射击方法:当英雄机调用一次射击方法时,就发射一个子弹* *///射击的方法public Bullet fire(){double x = this.x+w/2-4; //获取英雄机的x坐标Bullet bullet = new Bullet(x,y);//将处理过后的坐标传给子弹return bullet; //将子弹返回}//获取双倍子弹的方法int doubleTime = 0; // 双倍子弹的时间,20次public void getdouble_fire(){doubleTime = 20;}//双倍子弹方法public Bullet[] double_fire(){if(doubleTime>0){double x = this.x+w/2-7;double x1 = this.x+w/2-2; //获取英雄机的x坐标Bullet bullet1 = new Bullet(x,y);Bullet bullet2 = new Bullet(x1,y);//将处理过后的坐标传给子弹Bullet [] bullets = new Bullet[]{bullet1,bullet2};
//            return new Bullet[]{bullet1,bullet2};return bullets;}else {double x = this.x+w/2-4; //获取英雄机的x坐标Bullet bullet1 = new Bullet(x,y);return new Bullet[]{bullet1};}
//}//测试
//    public static void main(String[] args) {
//        Hero hero = new Hero();
//        hero.move(200,300);
//        Bullet bullet = hero.fire();
//        System.out.println(bullet.x+"  "+bullet.y);
//    }
}

6.敌机类Bee.java

package plane.gzeu;import javax.swing.*;public class Bee extends EnemyPlane implements Aword {double speed1;public Bee(){this.images = Images.bee;w = images[0].getIconWidth();h = images[0].getIconHeight();x=(int)(Math.random()*(420-images[0].getIconWidth()));y=-2*images[0].getIconHeight();this.step=(Math.random()*4.5+2.5);this.speed1=(Math.random()*3.5+0.5);
//        this.icon=new ImageIcon("images\\bee0.png");this.icon=Images.bee[0];life = 6;}public Bee(double x, double y, double w, double h,double step) {
//        super(x, y, w, h);this.step=step;this.icon = Images.bee[0];}@Overridepublic void move() {y+=speed1;x+=step;if(x>431-images[0].getIconWidth()){step = -step;}if(x<=0){step = -step;}}@Overridepublic int getAword() {return Math.random()>0.5?DOUBLE_FIRE:LIFE;}
}

7.背景类BG.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;//背景类(子类)
//继承FlyingObjesct类,得到FlyingObjesct类的方法及属性
public class BG extends FlyingObjesct {double y0;public BG(){x = 0;y = 0;icon = Images.bg;w = icon.getIconWidth();h = icon.getIconHeight();y0 = -h;step = 2;}public BG(double x, double y, double w, double h,double step) {super(x, y, w, h); //重载:调用父类的构造方法,实现方法复用this.step = step;this.icon = Images.bg; //背景是固定的}public void painting(Graphics g){icon.paintIcon(null,g,(int)x,(int)y);icon.paintIcon(null,g,(int)x,(int)y0);}@Overridepublic void move() {y+=step;y0+=step;if(y>=h){y=-h;}if(y0>=h){y0=-h;}}
}

8.爆炸类Bom.java

package plane.gzeu;import javax.swing.*;public class Bom extends EnemyPlane{public Bom(){x=(int)(Math.random()*370);y=(int)(Math.random()*370);this.step = 0.2;this.icon = Images.bom[0];}public Bom(double x, double y, double w, double h, double speed) {//要重写父类的构造方法。新增一个速度
//        super(x, y, w, h);//重载:调用父类的构造方法,实现方法复用this.step=speed;this.icon=Images.bom[0];}
}

9.子弹类Bullet.java

package plane.gzeu;import javax.swing.*;//继承FlyingObjesct类,得到FlyingObjesct类的方法及属性
public class Bullet extends EnemyPlane {public Bullet(double x,double y){this.icon = Images.bullet;w = icon.getIconWidth();h = icon.getIconHeight();this.x = x;this.y = y;step = 2;}public Bullet(){x=(int)(Math.random()*370);y=(int)(Math.random()*370);this.step = 0.2;this.icon = Images.bullet;}public Bullet(double x, double y, double w, double h, double step) {
//        super(x, y, w, h); //重载:调用父类的构造方法,实现方法复用this.step = step;this.icon = Images.bullet; //背景是固定的}@Overridepublic void move() {y-=step;}
}

10.三种敌机总类EnemyPlane.java

package plane.gzeu;
public abstract class EnemyPlane extends FlyingObjesct {@Overridepublic void move() {y+=step;}
}

11.飞行物的总类(父类)FlyingObjesct.java

package plane.gzeu;import javax.swing.*;
import java.awt.*;//飞行物的总类(父类)
public abstract class FlyingObjesct {public static final int LIVING = 1; //活着public static final int DEAD = 0; //死亡public static final int WAIT = -1;  //等待死亡(播放爆炸动画)//飞机默认是活着的public int state = LIVING;//飞机的生命值public int life = 2;public double x,y,step,w,h;//step速度public ImageIcon icon; //图片
//    Images images;public ImageIcon[] images; //数组public int index = 0;public ImageIcon [] boms = Images.bom; //存放爆炸效果的图片//赋初值:构造方法//快速生成构建方法:快捷键Alt+Insertpublic FlyingObjesct(double x, double y, double w, double h) {this.x = x;this.y = y;this.w = w;this.h = h;}//当飞机击打一次,生命值减一,当生命值为0时,进入死亡状态public boolean attack(){if(life>0){life--;if(life==0){state = DEAD;}return true;}return false;}
//让敌机快速去死public boolean goDead(){if(state==LIVING){life = 0;state = DEAD;return true;}else{return false;}}//判断飞机的三种状态public boolean isLiving(){return state==LIVING;  //判断是否活着}public boolean isDead(){return state==DEAD;  //判断是否死了}public boolean isWait(){return state==WAIT;  //判断是否等待死亡}/*实现动画效果* 1.用数组存储动画效果图片* 2.初始化数组* 3.定义一个计数器,作为切换图片的控制条件* 4.写一个方法,实现切换图片的操作* */int i;public void nextImage(){switch (state){case LIVING:if(images == null) {return;}icon = images[index++/300%images.length]; //0-[数组的长度-1]break;case DEAD:if(boms==null){return;}if(i++/300==boms.length){state = WAIT;return;}icon = boms[i++/300];}}public FlyingObjesct(){}//无参构造//移动public abstract void move();//绘制图形 方法public void painting(Graphics g){nextImage();icon.paintIcon(null,g,(int)x,(int)y);}//检测敌机是否碰到子弹:判断条件中心距c=H/2+h/2public boolean bong(FlyingObjesct bullet){FlyingObjesct p =this;double a = Math.min(p.w,p.h)/2;double b = Math.min(bullet.w,bullet.h)/2;double x1=p.x+p.w/2;double y1=p.y+p.h/2;double x2=bullet.x+bullet.w/2;double y2=bullet.y+bullet.h/2;double c = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));return c<=a+b;}//清除越界的敌机和子弹条件: y<-h-100 || y>700+100public boolean outOfBound(){if(y<-h-100){return true;}else if(y>700+100){return true;}return false;}
}

12.图片类Images.java

package plane.gzeu;import javax.swing.*;public class Images {public static ImageIcon bg;public static ImageIcon bullet;public static ImageIcon start;public static ImageIcon pause;public static ImageIcon gameover;public static ImageIcon[] hero;public static ImageIcon[] bigairplane;public static ImageIcon[] bee;public static ImageIcon[] airplane;public static ImageIcon[] bom;static {airplane = new ImageIcon[2];airplane[0] = new ImageIcon("images/airplane0.png");airplane[1] = new ImageIcon("images/airplane1.png");bigairplane = new ImageIcon[2];bigairplane[0] = new ImageIcon("images/bigairplane0.png");bigairplane[1] = new ImageIcon("images/bigairplane1.png");bee = new ImageIcon[2];bee[0] = new ImageIcon("images\\bee0.png");bee[1] = new ImageIcon("images\\bee1.png");bom = new ImageIcon[4];bom[0] = new ImageIcon("images/bom1.png");bom[1] = new ImageIcon("images/bom2.png");bom[2] = new ImageIcon("images/bom3.png");bom[3] = new ImageIcon("images/bom4.png");bg = new ImageIcon("images\\background.png");bullet = new ImageIcon("images\\bullet.png");start = new ImageIcon("images\\start.png");pause = new ImageIcon("images\\pause.png");gameover = new ImageIcon("images\\gameover.png");hero = new ImageIcon[2];hero[0] = new ImageIcon("images\\hero0.png");hero[1] = new ImageIcon("images\\hero1.png");}//测试图片是否传过来了public static void main(String[] args) {System.out.println(start.getImageLoadStatus()); //如果输出8那图片传过来了,输出其他数字有问题System.out.println(bg.getImageLoadStatus());System.out.println(bom[0].getImageLoadStatus());System.out.println(bee[1].getImageLoadStatus());System.out.println(airplane[1].getImageLoadStatus());}}

13.获得奖励的接口Aword.java

package plane.gzeu;
//获得奖励的接口
public interface Aword {int DOUBLE_FIRE = 1; //第一种奖励,双倍火力int LIFE = 2; //加生命值int getAword(); //获得奖励的方法
}

14.获得分数的接口Enemy.java

package plane.gzeu;
//获得分数的接口
public interface Enemy { //加分
//    int a = 5;//都是静态常量
//    public abstract void add(); //都是抽象方法public int getScore(); //获得分数的方法
}

运行界面:

开始界面

存活界面:

暂停界面

结束界面

相关文章:

用java编写飞机大战

游戏界面使用JFrame和JPanel构建。背景图通过BG类绘制。英雄机和敌机在界面上显示并移动。子弹从英雄机发射并在屏幕上移动。游戏有四种状态&#xff1a;READY、RUNNING、PAUSE、GAMEOVER。状态通过鼠标点击进行切换&#xff1a;点击开始游戏&#xff08;从READY变为RUNNING&am…...

java Map中get方法爆错NullPointerException

代码如下&#xff1a; public class Hello {public static void main(String[] args) {Map<Integer,Integer> map new HashMap<>();map.put(2,1);int i map.get(1); System.out.println(i);} }运行出错&#xff0c;看代码很明显是get到一个不存在map的值&#x…...

ElasticSearch备考 -- Multi field

一、题目 Create the index hamlet_2 with one primary shard and no replicas Copy the mapping of hamlet_1 into hamlet_2, but also define a multi-field for speaker. The name of such multi-field is tokens and its data type is the (default) analysed string Reind…...

刷题 图论

面试经典 150 题 - 图 200. 岛屿数量 dfs 标记 visited class Solution { public:// dfs 染色const int direction[4][2] {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};void dfs(vector<vector<char>>& grid, vector<vector<bool>>& visited, int x…...

基于JAVA的鲜花商城管理系统(源码+定制+讲解)鲜花商城管理系统、鲜花商城管理平台、鲜花商城信息管理、鲜花商城系统开发与应用、鲜花在线商城管理系统

博主介绍&#xff1a; ✌我是阿龙&#xff0c;一名专注于Java技术领域的程序员&#xff0c;全网拥有10W粉丝。作为CSDN特邀作者、博客专家、新星计划导师&#xff0c;我在计算机毕业设计开发方面积累了丰富的经验。同时&#xff0c;我也是掘金、华为云、阿里云、InfoQ等平台…...

深圳大学-Java程序设计-选实验1 基础知识练习

实验目的与要求&#xff1a; 实验目的&#xff1a;掌握Java程序设计开发环境的搭建&#xff0c;编写简单Java Project&#xff0c;掌握编译、运行等基本步骤和命令。 实验要求&#xff1a; (1).下载、安装"Java SE Development Kit 20.0.2"最新的版本&#xff0c;需…...

第 33 章 Ajax

第 33 章 Ajax 1.XMLHttpRequest 2.GET 与 POST 3.封装 Ajax 2005 年 Jesse James Garrett 发表了一篇文章&#xff0c;标题为&#xff1a;“Ajax&#xff1a;A new Approach to Web Applications”。他在这篇文章里介绍了一种技术&#xff0c;用他的话说&#xff0c;就叫&…...

LeetCode 209 Minimum Size Subarray Sum 题目解析和python代码

题目&#xff1a; Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there is no such subarray, return 0 instead. Example 1: Input: target 7, nu…...

C# 入坑JAVA 潜规则 注解 列表 listMch,该列表存储了一个映射(Map)的集合 等 入门系列3

java 项目结构 文件说明 潜规则 java入门-CSDN博客 C# 入坑JAVA 潜规则 大小写敏感文件名和类名 枚举等 入门系列2-CSDN博客 java注解 好像和C# 特性 差不多 Data Builder NoArgsConstructor AllArgsConstructor 在Java中&#xff0c;Data、Builder、NoArgsConstructor和Al…...

2024年9月个人工作生活总结

本文为 2024年9月工作生活总结。 研发编码 vuepress构建的几个问题 某vuepress项目&#xff0c;是我在3年多以前自行构想自行着手搞的&#xff0c;主要用于将一些常用的数据文件&#xff08;markdown样式&#xff09;渲染成html网页文件&#xff0c;在自建服务程序里开启访问…...

JVM有哪些参数以及如何使用

JVM&#xff08;Java虚拟机&#xff09;参数用于调整和优化Java应用程序的性能和行为。这些参数主要分为标准参数、非标准参数&#xff08;以-X开头&#xff09;和高级参数&#xff08;以-XX开头&#xff09;。以下是一些常见的JVM参数及其使用方法&#xff1a; 标准参数 -se…...

STM32编码器接口解析及抗噪声措施探讨

1. 引言 在现代控制系统中&#xff0c;编码器扮演着非常重要的角色。它就像一个精密的测量工具&#xff0c;可以告诉我们机械部件的位置和运动状态。在STM32微控制器中&#xff0c;编码器接口可以轻松地与各种编码器连接&#xff0c;实现精确的控制。我将在这里探讨STM32编码器…...

微软发布Windows 11 2024更新,新型Copilot+ AI PC功能亮相

前言 微软在Windows 11的2024更新中加强了对人工智能的应用&#xff0c;推出了新功能Copilot。 此次更新的版本号为26100.1742&#xff0c;Copilot将首先在Windows Insider中推出&#xff0c;计划于11月向特定设备和市场推广&#xff0c;用户需开启“尽快获取最新更新”选项以…...

鹏哥C语言68-70---位操作符+单目操作符+关系操作符

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <string.h> #include <time.h> //--------------------------------------------------------------------------------------------------------4.位操作符 // &----按&#xff08;2进制…...

showdoc二次开发

showdoc用的vue版本老&#xff0c;需要安装老版本nodejs&#xff0c;比如node 14.21.3 win32-x64-93_binding.node问题 https://github.com/sass/node-sass/releases 下载 web_src\node_modules\node-sass\vendor\win32-x64-93 下面重命名为binding.node 代理到php后端&…...

力扣16~20题

题16&#xff08;中等&#xff09;&#xff1a; 思路&#xff1a; 双指针法&#xff0c;和15题差不多&#xff0c;就是要排除了&#xff0c;如果total<target则排除了更小的&#xff08;left右移&#xff09;&#xff0c;如果total>target则排除了更大的&#xff08;rig…...

Pikachu-Sql-Inject -基于boolian的盲注

基于boolean的盲注: 1、没有报错信息显示&#xff1b; 2、不管是正确的输入&#xff0c;还是错误的输入&#xff0c;都只显示两种情况&#xff0c;true or false&#xff1b; 3、在正确的输入下&#xff0c;输入and 1 1/and 1 2发现可以判断&#xff1b; 布尔盲注常用函数&…...

最后30天,你的系统集成项目管理工程师备考进度到哪儿了?

十一长假归来好&#xff01; 此次归来之后&#xff0c;2024年下半年软考倒计时就从4字头切换到了3字头&#xff0c;今天距离考试还有32天&#xff01; 那么问题来了&#xff0c;临近考试还有30天左右的时候&#xff0c;你的备考进度到哪里了呢&#xff1f; 其实无论目前你的实际…...

网络安全事件的发生,主要原因是什么

网络安全事件的发生&#xff0c;主要原因涉及多个方面&#xff0c;包括技术漏洞、人为因素、经济利益驱动、恶意软件和病毒威胁、社会工程学攻击、内部人员恶意行为、供应链安全问题以及法律法规的不完善等。以下是对这些原因的详细分析&#xff1a; 技术漏洞&#xff1a; 软件…...

【leetcode】274.H指数

为了方便&#xff0c;将 citations 记为 cs。 所谓的 h 指数是指一个具体的数值&#xff0c;该数值为“最大”的满足「至少发表了 x 篇论文&#xff0c;且每篇论文至少被引用 x 次」定义的合法数&#xff0c;重点是“最大”。 用题面的实例 1 来举个 &#x1f330;&#xff0…...

1.Python 引入(字面量、注释、变量、数据类型、数据类型转换、标识符、运算符、字符串扩展)

一、字面量 1、基本介绍 在代码中&#xff0c;被写直接下来的、不需要通过变量存储的值&#xff0c;称之为字面量 2、常用值类型 类型说明数字&#xff08;Number&#xff09;整数&#xff08;int&#xff09;&#xff0c;例如&#xff1a;10、-10浮点数&#xff08;float&…...

【AI知识点】梯度消失(Vanishing Gradient)和梯度爆炸(Exploding Gradient)

梯度消失&#xff08;Vanishing Gradient&#xff09; 和梯度爆炸&#xff08;Exploding Gradient&#xff09; 是神经网络训练中的常见问题&#xff0c;特别是在深层神经网络&#xff08;DNN&#xff09;或递归神经网络&#xff08;RNN&#xff09;中。这两者主要与反向传播算…...

在 ArkTS 网络请求中,重新封装一下 http 模块

在ArkTS中&#xff0c;重新封装http模块可以提供一个更简洁、更易于使用的API&#xff0c;同时隐藏底层细节&#xff0c;使开发者能够更专注于业务逻辑。以下是一个简单的示例&#xff0c;展示了如何重新封装鸿蒙系统的kit.NetworkKit中的http模块&#xff1a; // 创建一个新的…...

Microsoft 更新 Copilot AI,未來將能使用語音並看到你瀏覽的網頁

不過受到 Recall 事件的影響&#xff0c;更新的推出將更緩慢謹慎。 Microsoft 也同步對其網頁版及行動版的 Copilot AI 進行大改版。這主要是為網頁版換上了一個較為簡單乾淨的介面&#xff0c;並增加了一些新的功能&#xff0c;像是 Copilot Voice 能讓你與 AI 助手進行對話式…...

系统架构设计师-论文题(2021年下半年)

1.试题一 论面向方面的编程技术及其应用针对应用开发所面临的规模不断扩大、复杂度不断提升的问题&#xff0c;面向方面的编程Aspect Oriented Programming,AOP技术提供了一种有效的程序开发方法。为了理解和完成一个复杂的程序&#xff0c;通常要把程序进行功能划分和封装。一…...

selenium的webdriver常用方法和属性介绍(2)

selenium的webdriver介绍 从selenium导入webdriver模块&#xff0c;在pycharm中跳转webdriver模块的__init__.py文件&#xff0c;内容如图所示&#xff1a;从selenium包的子目录中导入了很多模块并做了重命名&#xff0c;用于支持如下 Chrome/Edge/Ie/Firefox/Safari浏览器。 使…...

73.【C语言】C/C++的内存区域划分

目录 1.内存里的几个区域 2.示意图 3.解释 1.内存里的几个区域 除了耳熟能详的栈区,堆区,静态区,还有内核空间,内存映射段,数据段,代码段 2.示意图 3.解释 栈区(stack area):局部变量,函数参数,返回数据,返回地址 内存映射段:将文件映射到内存 映射的含义: 如果看过李忠…...

k8s 中存储之 hostPath 卷

目录 1 hostPath 卷介绍 2 hostPath 卷实际应用操作 2.1 创建 pod 资源类型 2.2 修改清单文件增加 hostPath 对应的参数配置 2.3 查看是否创建 卷 和 pod 2.4 创建发布文件测试是否正常访问 1 hostPath 卷介绍 EmptyDir中数据不会被持久化&#xff0c;它会随着Pod的结束而销…...

Cherno游戏引擎笔记(73~90)

------- scene viewport ---------- 》》》》做了两件事&#xff1a;设置视口和设置相机比例 》》》》为什么要设置 m_ViewportSize 为 glm::vec2 而不是 ImVec2 ? 因为后面需要进行 ! 运算&#xff0c;而 ImVec2 没有这个运算符的定义&#xff0c;只有 glm::vec2 有这个运算…...

helm 测试卸载或删除(redis)

作者&#xff1a;程序那点事儿 日期&#xff1a;2024/02/07 18:30 查看redis 集群实例 kubectl get all -n redis 卸载集群实例 helm uninstall redis -n redis 删除pvc kubectl get pvc -n redis kubectl delete pvc redis-data-redis-master-0 redis-data-redis-replicas…...