Java游戏《飞机大战》

news/2024/10/17 18:27:48/

作品展示

如有需要素材或者疑问可以关注点赞私信哦

登录页面

游戏页面

页面标签都可以进行点击操作

 代码展示

1 定义一个main方法作为游戏入口

 2 用JFrame绘制游戏面板

package Login;import Login.IfCode;
import Login.User;
import ikun.second.beginGame.BeginGame;import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;public class LonginUI extends JFrame implements ActionListener, MouseListener
{static ArrayList<User>allUsers=new ArrayList<>();//创建一个集合,存储用户名和密码static{allUsers.add(new User("虎儿真帅","123456"));allUsers.add(new User("lyh123","654321"));}JButton jb=new JButton();JLabel jlname=new JLabel("账号");JLabel jlpassed=new JLabel("密码");JLabel jlif=new JLabel("验证码");JTextField jtname=new JTextField(30);JPasswordField jppassed=new JPasswordField(30);JTextField jtf  =new JTextField();//验证码文本框//JTextField tf =new JTextField();//随机生成的验证码文本框JLabel tf=new JLabel();JLabel explain=new JLabel("游戏介绍");JLabel state=new JLabel("操作说明");private JPanel contentPane;JFrame jf=new JFrame();public LonginUI(){setBg();init();//this.setVisible(true);}public void setBg(){((JPanel)jf.getContentPane()).setOpaque(false);ImageIcon img = new ImageIcon("C:\\Users\\16190\\Desktop\\log.png");JLabel background = new JLabel(img);jf.getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));background.setBounds(0, 0, img.getIconWidth(), img.getIconHeight());}public void init(){//jf.setLayout(null);jf.setTitle("登录页面");jf.setBounds(300,150,500,800);jf.setLayout(null);jf.setResizable(false);jf.setBackground(Color.CYAN);jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);jf.setLocationRelativeTo(null);//jf.setFont();//1按扭 登录jb.setIcon(new ImageIcon("C:\\Users\\16190\\Desktop\\log1.png"));jb.setBounds(180,540,150,60);jb.addMouseListener(this);jb.setBorderPainted(false);//去除按钮的边框jb.setContentAreaFilled(false);//设置按钮透明jf.getContentPane().add(jb);//标签  用户名jlname.setBounds(100,380,30,30);//jlname.setFont(new Font("微软雅黑",Font.BOLD,10));jf.add(jlname);jlname.setVisible(true);//密码文字jlpassed.setBounds(100,430,30,30);jf.add(jlpassed);jlpassed.setVisible(true);//验证码jlif.setBounds(90,480,50,30);jf.add(jlif);jlif.setVisible(true);//可视化在所有组件加载之后jf.setVisible(true);//可视化,交给系统渲染到屏幕上//组件设置尺寸// 文本框大小 用户文本框jtname.setBounds(150,380,200,35);jf.add(jtname);jf.setVisible(true);//密码文本框jppassed.setBounds(150,430,200,35);jf.add(jppassed);//界面窗体中增加按钮jf.setVisible(true);//验证码文本框jtf.setBounds(150,480,100,35);jf.add(jtf);//随机验证码文本框//tf.setBounds(270,483,60,30);//获取生成的验证码String codestr= IfCode.randomcode(4);//System.out.println(codestr);tf.setText(codestr);//设置内容,在标签上添加验证码tf.addMouseListener(this);//绑定鼠标事件tf.setBounds(270,483,60,30);//位置和宽高jf.getContentPane().add(tf);//将随机生成的验证码添加到界面explain.setBounds(10,0,80,80);explain.setFont(new Font("微软雅黑",Font.BOLD,15));explain.addMouseListener(this);jf.getContentPane().add(explain);state.setBounds(400,0,80,80);state.setFont(new Font("微软雅黑",Font.BOLD,15));state.addMouseListener(this);jf.getContentPane().add(state);}@Overridepublic void actionPerformed(ActionEvent e)//点击鼠标发生的事件{}@Overridepublic void mouseClicked(MouseEvent e){if(e.getSource()==jb){//就是获得你目前这个事件的事件源,说通俗点,比如有一个按钮事件,// 你点击一个按钮,在处理事件中你用e.getSource(),就是获得这个按钮System.out.println("点击登录按钮");//获取俩个输入文本框的内容String usernameInput= jtname.getText();char[] passwordInput= jppassed.getPassword();String str =new String(passwordInput);String codeInput=jtf.getText();//获取用户输入的验证码//创建一个user对象User userInfo=new User(usernameInput,str);//把用户名和密码放入对象中System.out.println("用户输入的用户名是"+usernameInput);System.out.println("用户输入的密码是"+str);if (contains(userInfo)&&codeInput.equalsIgnoreCase(tf.getText())){System.out.println("输入正确");jf.setVisible(false);//关闭当前登录界面BeginGame frame =new BeginGame();}else{if(usernameInput.length()==0||passwordInput.length==0||codeInput.length()==0){System.out.println("用户名,密码或验证码为空");showJDialog("用户名,密码或验证码为空");System.out.println("随机更换一个新的验证码");String code=IfCode.randomcode(4);//获取一个新的验证码tf.setText(code);}else if( !codeInput.equalsIgnoreCase(tf.getText())){showJDialog("您输入账户或密码或验证码有误");String code=IfCode.randomcode(4);//获取一个新的验证码tf.setText(code);} else  {showJDialog("您输入账户或密码或验证码有误");String code=IfCode.randomcode(4);//获取一个新的验证码tf.setText(code);}}if(e.getSource()== explain){System.out.println("dianjij");}}if (e.getSource()==tf){//点击屏幕验证码可以更换验证码System.out.println("更换验证码");String code=IfCode.randomcode(4);tf.setText(code);}if (e.getSource()==explain){//利用网页进行对话框换行show1JDialog("<html><body><p>" +"《飞机大战》这是一款经典飞行射击类游戏,<br/>" +"精美绚丽的画面,整体环境主要还是围绕太空为主,<br/>" +"高保真的音效,为玩家呈现一场不一样射击体验。<br/></p></body></html>");}if (e.getSource()==state){show1JDialog("<html><body><p>" + "使用键盘方向键↑↓←→键或鼠标控制飞机移动,自动发射子弹<br/>当击中敌机时,增加1分," +"被敌机打到时扣除一个生命值分数减10。<br/>吃到道具机子弹增加,最多加三颗,然后会增加生命值<br/>并且敌机的速度根据敌机大小不同速度不同," +"撞上敌机时游戏结束。<br/></p></body></html>");}}private void show1JDialog(String s) {JDialog jDialog1=new JDialog();//创建一个弹窗对象jDialog1.setSize(400,200);  //设置弹窗大小jDialog1.setAlwaysOnTop(true);//让弹窗顶置jDialog1.setLocationRelativeTo(null);//让弹窗居中jDialog1.setModal(true);//模式对话框,弹框不关闭无法操作下面的界面//创建标签对象管理文字并添加到弹框中JLabel sout=new JLabel(s);//创建新的标签,内容是输出的showJDialogsout.setBounds(0,0,80,60);//设置标签大小sout.setFont(new Font("微软雅黑",Font.BOLD,15));jDialog1.getContentPane().add(sout);//setContentPane()/getContentPane()添加或设置组件, JFrame 有一个 Content Pane,// 窗口能显示的所有组件都是添加在这个 Content Pane 中。JFrame 提供了两个方法:// getContentPane 和 setContentPane 就是用于获取和设置其 Content Pane 的。jDialog1.setVisible(true);//让弹框显示出来}private boolean contains(User userInput) {//userIput为用户输入的账号,密码for (int i = 0; i < allUsers.size(); i++) {//size()返回类表中元素的个数User rightUser=allUsers.get(i);//get()返回类表中指定的元素//比较用户名和密码是否相同if (userInput.getUsername().equals(rightUser.getUsername())&&userInput.getPassword().equals(rightUser.getPassword())){return true;//有相同的代表存在,返回true}}// showJDialog("您输入账户或密码或验证码有误");return false;//循环结束之后还没有找到就表示不存在}private void showJDialog(String content) {JDialog jDialog=new JDialog();//创建一个弹窗对象jDialog.setSize(200,150);  //设置弹窗大小jDialog.setAlwaysOnTop(true);//让弹窗顶置jDialog.setLocationRelativeTo(null);//让弹窗居中jDialog.setModal(true);//模式对话框,弹框不关闭无法操作下面的界面//创建标签对象管理文字并添加到弹框中JLabel sout=new JLabel(content);//创建新的标签,内容是输出的showJDialogsout.setBounds(0,0,200,150);//设置标签大小jDialog.getContentPane().add(sout);//setContentPane()/getContentPane()添加或设置组件, JFrame 有一个 Content Pane,// 窗口能显示的所有组件都是添加在这个 Content Pane 中。JFrame 提供了两个方法:// getContentPane 和 setContentPane 就是用于获取和设置其 Content Pane 的。jDialog.setVisible(true);//让弹框显示出来}@Overridepublic void mousePressed(MouseEvent e){if (e.getSource() == jb){jb.setIcon(new ImageIcon("C:\\Users\\16190\\Desktop\\log1.png"));}}@Overridepublic void mouseReleased(MouseEvent e){}@Overridepublic void mouseEntered(MouseEvent e) {}@Overridepublic void mouseExited(MouseEvent e) {}
}

3 展示验证码功能(验证码可以通过鼠标点击更换)

package Login;import java.util.Random;public class IfCode {public IfCode(){String code=randomcode(4);//System.out.println(code);}public static String randomcode(int n){String code ="";for (int i = 0; i < n; i++) {Random r=new Random();int type=r.nextInt(3);switch (type){case 0:char ch  =(char)(r.nextInt(25)+65);code+=ch;break;case 1:char ch1=(char)(r.nextInt(25)+97);code+=ch1;break;case 2:code+=r.nextInt(9);break;}}return code;}}

利用JavaBean进行定义游戏的登录用户名和密码的设置

package Login;
public class User  {private String username;//用户名private String password;//密码//定义一个无参构造器public User(){}public User(String username, String password){this.username=username;this.password=password;}public void setUsername(String username){this.username=username;}public String getUsername(){return username;}public void setPassword(String password){this.password=password;}public String getPassword(){return password;}}


游戏开始界面

游戏初始界面

package ikun.second.beginGame;import javax.swing.*;/*** 游戏的窗体绘制* Java中的游戏窗体绘制类是JFrame* 自定义窗体绘制的步骤* 1写一个类,继承JFrame* 2写一个构造方法,绘制窗口的属性* 属性对应特点,方法对应行为*/
public class BeginGame extends JFrame {/*** 构造方法;方法名与类名一致**/public BeginGame(){begin();this.setVisible(true);//让界面显示出来}//explise中Alt+?开启代码提示public void begin(){this.setSize(512, 768);//设置界面的宽高this.setTitle("飞机大战"); //设置界面的标题//this.setAlwaysOnTop(true); //设置界面置顶this.setLocationRelativeTo(null);//设置界面居中this.setResizable(false);//设置游戏界面不可以改变this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭模式//this.setLayout(null);  //取消默认的居中放置,只有取消了才会按照XY轴的形式添加组件GamePanel panel=new GamePanel(this);//创建面板对象,调用面板的构造方法,制作面板()中添加的this为frame,将其添加到窗口中panel.action();//调用敌机的方法this.add(panel);//将面板添加到窗体中}}

游戏页面制作

package ikun.second.beginGame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
*  Java中的游戏面板; JPanel
*  自定义游戏面板
*  1写一个类继承JPanel
*  2写一个构造方法,初始化面板的属性
*/
public class GamePanel extends JPanel {BufferedImage bg;//初始化背景Hero hero=new Hero();// Enemy en =new Enemy();//创建敌机的集合的,存放所有的敌机List<Enemy> ens=new ArrayList<Enemy>();List<Fire> fs=new ArrayList<Fire>();int score;boolean gameover=false;int power=1;boolean isStart=false;boolean isWin;/*** 使用线程开启一个游戏* 线程的格式* new Thread(){public void run(){....线程所有要完成的事情。。。。}}.start();*/public void action(){new Thread(){public void run(){while(true){ //写一个死循环让敌机一直进入游戏if (!gameover&&isStart==true&&isWin==false){//调用敌机入场的方式ensEnter();//调用方法让敌机移动ensMove();//调用方法发射子弹shoot();//让子弹移动fireMove();//子弹射击敌机shootEp();//判断敌机是否撞到了英雄机hit();}else{isStart=false;}//调用线程休眠,没执行一次,暂停一会try {Thread.sleep(9);} catch (InterruptedException e) {throw new RuntimeException(e);}repaint();}}private void hit() {//遍历敌机for (int i = 0; i < ens.size(); i++) {Enemy e=ens.get(i);//如果敌机被英雄机撞上if (e.hitBy(hero)){//删除敌机ens.remove(e);//英雄机血量减少hero.hp--;power=1;//英雄机血量火力减少score-=10;if (hero.hp<=0){gameover=true;}}}}private void shootEp() {//遍历所有的子弹for (int i = 0; i < fs.size(); i++) {//获取每一刻子弹Fire f=fs.get(i);//让没一颗子弹,判断是否集中敌机bang(f);}  }/*** 判断每一颗子弹是否击中敌机** @param f*/private void bang(Fire f) {//遍历所有敌机for (int i = 0; i < ens.size(); i++) {//获取每一个敌机Enemy e=ens.get(i);//判断敌机是否击中了子弹if(e.shootBy(f)){if (e.type!=15){//让敌机的血量减少e.hp--;//如果子弹击中敌机,敌机消失//当敌机血量减少到0时;if (e.hp<=0){if (e.type==5||e.type==6){power++;if (power>3){hero.hp++;power=3;}}ens.remove(e);//敌机消失score+=1;  //增加分数}if (score>=10){isWin=true;}}fs.remove(f); //子弹消失}}}//子弹移动的方法private void fireMove() {for(int i=0;i<fs.size();i++){Fire f=fs.get(i);f.move();//f.y=f.y-f.sp;}}//发射子弹的方法int findxe=0;private void shoot() {findxe++;if(findxe>=5){if (power==1){Fire fire2=new Fire(hero.x+25,hero.y-15,1);fs.add(fire2);} else if (power==2) {Fire fire1=new Fire(hero.x+50,hero.y,2);fs.add(fire1);//中间Fire fire2=new Fire(hero.x+25,hero.y-15,1);fs.add(fire2);}else {//左边Fire fire=new Fire(hero.x,hero.y,0);fs.add(fire);Fire fire1=new Fire(hero.x+50,hero.y,2);fs.add(fire1);//中间Fire fire2=new Fire(hero.x+25,hero.y-15,1);fs.add(fire2);//增加子弹}findxe=0;//如果放在if语句外面,则没有机会执行if语句里面的内容}}protected void ensMove() {//遍历所有敌机for(int i=0;i<ens.size();i++){Enemy en=ens.get(i);en.move();}}//实现ensEnter()方法//敌机出现的频率太高,执行20次 ensEnter()方法,才创建一个敌机int index=0;protected void ensEnter() {index++;if(index>=20){Enemy e=new Enemy();ens.add(e);index=0;}}}.start();}public GamePanel( BeginGame frame){//定义一个构造方法,添加窗体setBackground(Color.PINK);//设置面板的背景//将背景图导入bg=App.getPicture("/picture/bg3.jpg");//MouseAdapter是抽象的abstract,不能实例化/*** 使用鼠标监听器的固定格式* 1 创建鼠标适配器* 2 确定所需要的鼠标的事件* 鼠标事件有* 1 mouseMoved 监听鼠标移动事件* 2 mouseCliked 监听鼠标点击事件* 3 mousePressed 监听鼠标按下去事件* 4 mouseEntered 监听鼠标移入游戏界面事件* 5 mouseExited 监听鼠标移出游戏界面事件*/MouseAdapter adapter=new MouseAdapter(){@Overridepublic void mouseClicked(MouseEvent e) {if (gameover||isWin){hero=new Hero();gameover=false;isWin=false;score=0;ens.clear();//清楚敌机fs.clear();//清除子弹power=1;//子弹等于1;Random r=new Random();int index=r.nextInt(3)+3;bg=App.getPicture("/picture/bg"+index+".jpg");repaint();} else  {isStart=!isStart;}}@Overridepublic void mouseMoved(MouseEvent e){/*** 当鼠标在游戏界面中移动时,会触动该方法,使得英雄机和鼠标一起移动* 既是让鼠标的横纵坐标和英雄机的横纵坐标一致*/int mx=e.getX();//鼠标的横坐标int my=e.getY();//鼠标的横坐标if (!gameover&&isStart==true){//让英雄机移动到鼠标的位置hero.moveToMouse(mx,my);}//刷新页面,讲英雄级绘制到新的位置repaint();}};//将适配器加入到监听器中(固定模式)addMouseListener(adapter);addMouseMotionListener(adapter);/*** 使用鼠标监听器* 1 创建鼠标适配器* 2 确定需要监听的键盘事件*/KeyAdapter kd=new KeyAdapter() {@Override//按下键盘会触动该方法public void keyPressed(KeyEvent e) {int keycode=e.getKeyCode();// System.out.println(keycode);if(keycode==KeyEvent.VK_UP||keycode==KeyEvent.VK_W){// hero.y=hero.y-10;hero.moveUP();}else if(keycode==KeyEvent.VK_DOWN||keycode==KeyEvent.VK_S){//hero.y=hero.y+10;hero.moveDOWN();}else if(keycode==KeyEvent.VK_RIGHT||keycode==KeyEvent.VK_D){//hero.x=hero.x+10;hero.moveRIGHT();} else if (keycode==KeyEvent.VK_LEFT||keycode==KeyEvent.VK_A) {//hero.x=hero.x-10;hero.moveLEFT();}//hero.moveToKey(150,500);repaint();}};frame. addKeyListener(kd);//frame 必须将键盘添加到窗体中}/**
*Graphics g 是画笔* paint()是画图方法*/@Overridepublic void paint(Graphics g){super.paint(g);// g.drawImage(bg,0,0,null);//如果不是原图,想要改变图片大小,可以用g.drawImage(bg,0,0,512,768,null);//设置图片的大小,并将其画在画板上// 如果图片与窗口一致  g.drawImage(bg,200,300,null);g.setColor(Color.white);g.setFont(new Font("楷体",Font.BOLD,18));g.drawString("分数"+score,10,30);//画敌机g.drawImage(hero.img,hero.x,hero.y,hero.w,hero.h,null);for (int i = 0; i < ens.size(); i++) {Enemy en=ens.get(i);g.drawImage(en.img,en.x,en.y,en.w,en.h,null);}//画子弹for(int i=0;i<fs.size();i++){Fire fire=fs.get(i);g.drawImage(fire.img,fire.x,fire.y,fire.h,fire.w,null);}//画英雄级的血量for (int i = 0; i < hero.hp; i++) {g.drawImage(hero.img,360+i*35,5,30,30,null);}//画死亡判断if (gameover){g.setColor(Color.red);g.setFont(new Font("楷体",Font.BOLD,35));g.drawString("GAMEOVER,你个小菜鸡,",80,300);g.drawString("点击屏幕重新开始游戏",80,350);}else if(isStart==false){g.setColor(Color. WHITE);g.setFont(new Font("微软雅黑",Font.ITALIC,40));g.drawString("点击屏幕开始游戏", 90, 350);}if (isWin){g.setColor(Color. pink);g.setFont(new Font("微软雅黑",Font.ITALIC,60));g.drawString("恭喜通关", 120, 300);}}
}
定义一个工具类,处理游戏图片
package ikun.second.beginGame;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
/**
* APP类是处理图片的工具类
* 工具类的使用; 工具类一般讲项目重复使用的代码抽离出来,定义成工具方法
*              工具类中的方法,一般用static修饰
*
* 家static的目的;
* static是公用的,被锁有对象公用
* static修饰的方法不依赖用对象,可以用类名直接调用
*/
public class App {/***BufferedImage Java中用来表示图片的类* /读取指定位置上的图片* path图片的路径* getResource()获取想要得到的资源*/public static BufferedImage getPicture(String path){/***加载图片* Java中的IO,传送数据的管道* 表示输入输出流* App.class找到App类的路径*/try {BufferedImage picture= ImageIO.read(App.class.getResource(path));//如果未找到图片,将图片返回return picture;} catch (IOException e) {//catch如果找不到图片,就会捕获找不到图片的原因e.printStackTrace();}return null;}
}


定义一个敌机类

package ikun.second.beginGame;import java.awt.image.BufferedImage;
import java.util.Random;public class Enemy extends FlyObject {int sp;int hp;int type;public Enemy(){//设置一个随机数,随机产生敌机的位置Random r=new Random();int index=r.nextInt(15)+1;//刚开始是[0,15)0~14,  +1之后为[1,16)取值范围是1~15;type=index;//三元运算符判断String path="/picture/ep"+(index<10?0:"")+index+".png";img=App.getPicture(path);//获取敌机的图片//定义敌机的属性,大小,宽高w=img.getWidth();h=img.getHeight();x=r.nextInt(512-w);//飞机随机产生的位置减去飞机自身的宽度y=-h;sp=17-index;hp=index+1;}public void move(){if (type==12){x-=5;y+=5;} else if (type==13) {x+=5;y+=5;} else if (type==15) {y+=10;}else{y+=sp;}}
}
定义英雄机类
package ikun.second.beginGame;
public class Hero extends FlyObject {int hp;public Hero(){//导入英雄机的图片img=App.getPicture("/picture/ep16.png");//确定英雄机在游戏开始时显示的位置x=150;y=500;//确定英雄机的大小w=img.getWidth()/2;h=img.getHeight()/2;hp=3;}public void moveToMouse(int mx,int my){x=mx-w/2;y=my-h/2;}public void moveUP(){y=y-10;}public void moveDOWN(){y=y+10;}public void moveRIGHT(){x=x+10;}public void moveLEFT(){x=x-10;}
}

定义英雄机和敌机共同属性的类

package ikun.second.beginGame;import java.awt.image.BufferedImage;public class FlyObject {/*** 定义飞机的属性,如位置,大小* 飞机的的图片,把所有的飞机图片的导入声明,大小,宽高,等属性封装成一个父类,* 其他类如需调用,让其子类继承父类中的变量*/BufferedImage img;int x;int y;int w;int h;public void move() {y=y-10;}//碰撞监测,敌机是否被子弹击中public boolean shootBy(Fire f) {boolean hit =x<=f.x+f.w&&x>=f.x-w&&y<=f.y+f.h&&y>=f.y-h;return hit;}public boolean hitBy(Hero f) {boolean hit =x<=f.x+f.w&&x>=f.x-w&&y<=f.y+f.h&&y>=f.y-h;return hit;}
}
定义子弹类
package ikun.second.beginGame;public class Fire extends FlyObject{/*** 定义一个构造方法* 初始化子弹*/int dir;public Fire(int hx,int hy,int dir){//子弹图片导入img=App.getPicture("/picture/fire.png");//确定子弹大小w=img.getWidth()/4;h=img.getHeight()/4;//确定子弹的位置x=hx;y=hy;this.dir=dir;if (dir==0){y-=10;x-=3;} else if (dir==1) {y-=10;}else if (dir==2){x+=3;y-=10;}}
}


http://www.ppmy.cn/news/598236.html

相关文章

Java经典飞机大战游戏

《飞机大战》这款小游戏相信许多朋友早就已经玩过&#xff0c;但是作为小白&#xff0c;学习过程中就是要拿各种经典项目来练手&#xff0c;飞机大战就是老师拿来让我们练手的一个小项目。老师给我们提供了素材包&#xff0c;让我们自由发挥&#xff0c;刚开始真的是没什么头绪…

Docker-compose 安装 Nacos2.x并配置mysql数据库存储

1.安装Nacos 1.1 创建数据库nacos并导入sql 在mysql数据库中创建nacos并导入nacos-db.sql。这个sql在安装包中有提供。 1.2 创建docker-compose version: 3services:nacos:image: nacos/nacos-server:[版本号]container_name: nacosports:- 8848:8848- 9848:9848- 9849:984…

电机飞车现象

什么是飞车现象&#xff1f; 直流电动机转速失去控制&#xff0c;大电流大转矩加速运行。因转速太高而导致直流电动机和机械损坏。 在运转时&#xff0c;&#xff08;直流&#xff09;电机突然的失磁&#xff0c;导致电枢过电流而产生很大的加速变化&#xff0c;放炮或跳闸。…

机车风暴3制作揭密译文

译自 DIGITAL FOUNTRY 网站对 机车风暴3制作团队的采访全文&#xff0c;图片及文字全部翻译完毕&#xff0c;欢迎各位同学讨论、批评、指正。原贴地址&#xff1a; http://www.eurogamer.net/article ... m-apocalypse?page1 译文全文如下&#xff1a; 机车风暴3的制作过程揭…

什么是断路器?谈谈服务雪崩效应?服务雪崩效应产生的原因?

短路器&#xff1a; 熔断机制&#xff08;短路器&#xff09;是应对雪崩效应的一种微服务链路保护机制。 当链路的某个微服务出错不可用或者响应时间太长时&#xff0c;会进行服务的降级&#xff0c;进而熔断该节点微服务的调用&#xff0c;快速返回错误的响应信息。当检测到…

CPP使用const的情况

文章目录 使用示例const常量引用和普通引用常量引用和普通引用区别示例报错原因 使用示例 在 C 中&#xff0c;我们使用 const 关键字来表示一个常量&#xff0c;即其值在编译时就已经被设定并且在运行时不能被改变。 例如131.分割回文串&#xff0c;最开始传入的字符串strin…

JMeter在高分辨率电脑上,页面显示字体特别小

最近使用JMeter的过程中&#xff0c;发现一个问题&#xff0c;在高分辨率的电脑上&#xff0c;JMeter启动后&#xff0c;页面显示的字体特别小&#xff0c;上图 我电脑的分辨率是2880*1800&#xff0c;缩放200% 上图里显示的字体真心看不清楚 我以为是JMeter的bug&#xff0c…

2023-06-27 LeetCode每日一题(删除一次得到子数组最大和)

2023-06-27每日一题 一、题目编号 1186. 删除一次得到子数组最大和二、题目链接 点击跳转到题目位置 三、题目描述 给你一个整数数组&#xff0c;返回它的某个 非空 子数组&#xff08;连续元素&#xff09;在执行一次可选的删除操作后&#xff0c;所能得到的最大元素总和…