Java实现飞机射击游戏:从设计到完整源代码

JAVA打飞机游戏毕业设计

一、游戏概述

本游戏基于Java Swing开发,实现了经典的飞机射击游戏。玩家控制一架战斗机在屏幕底部移动,发射子弹击落敌机,同时躲避敌机攻击。游戏包含多个关卡,随着关卡提升,敌机速度和数量会逐渐增加,难度逐步提升。游戏具有计分系统、生命值系统、音效和动画效果,提供了良好的用户体验。

二、系统架构设计

1. 技术选型

  • 开发语言:Java SE
  • 图形界面:Java Swing
  • 音频处理:Java Sound API
  • 开发工具:IntelliJ IDEA

2. 系统架构

├── src
│   ├── main
│   │   ├── java
│   │   │   └── com
│   │   │       └── aircraftgame
│   │   │           ├── main (主程序)
│   │   │           ├── model (游戏模型)
│   │   │           ├── view (游戏视图)
│   │   │           ├── controller (游戏控制器)
│   │   │           ├── utils (工具类)
│   │   │           └── resource (资源类)

三、核心代码实现

1. 游戏主类

// MainGame.java
package com.aircraftgame.main;import com.aircraftgame.controller.GameController;
import com.aircraftgame.view.GameFrame;public class MainGame {public static void main(String[] args) {// 创建游戏控制器GameController controller = new GameController();// 创建游戏窗口GameFrame gameFrame = new GameFrame(controller);// 初始化游戏controller.initGame(gameFrame);// 启动游戏controller.startGame();}
}

2. 游戏模型

// GameObject.java
package com.aircraftgame.model;import java.awt.*;public abstract class GameObject {protected int x;protected int y;protected int width;protected int height;protected int speed;protected boolean alive;public GameObject(int x, int y, int width, int height, int speed) {this.x = x;this.y = y;this.width = width;this.height = height;this.speed = speed;this.alive = true;}public abstract void update();public abstract void draw(Graphics g);public Rectangle getBounds() {return new Rectangle(x, y, width, height);}public boolean isAlive() {return alive;}public void setAlive(boolean alive) {this.alive = alive;}public int getX() {return x;}public void setX(int x) {this.x = x;}public int getY() {return y;}public void setY(int y) {this.y = y;}public int getWidth() {return width;}public int getHeight() {return height;}public int getSpeed() {return speed;}public void setSpeed(int speed) {this.speed = speed;}
}// Player.java
package com.aircraftgame.model;import com.aircraftgame.resource.Resources;import java.awt.*;
import java.util.ArrayList;
import java.util.List;public class Player extends GameObject {private static final int DEFAULT_SPEED = 8;private static final int DEFAULT_LIVES = 3;private static final int FIRE_INTERVAL = 200; // 射击间隔,毫秒private int lives;private long lastFireTime;private List<Bullet> bullets;private boolean movingLeft;private boolean movingRight;private boolean movingUp;private boolean movingDown;public Player(int x, int y) {super(x, y, Resources.playerImage.getWidth(), Resources.playerImage.getHeight(), DEFAULT_SPEED);this.lives = DEFAULT_LIVES;this.bullets = new ArrayList<>();this.lastFireTime = 0;}@Overridepublic void update() {// 更新玩家位置if (movingLeft && x > 0) {x -= speed;}if (movingRight && x < 700 - width) {x += speed;}if (movingUp && y > 0) {y -= speed;}if (movingDown && y < 500 - height) {y += speed;}// 更新子弹for (Bullet bullet : new ArrayList<>(bullets)) {bullet.update();if (!bullet.isAlive()) {bullets.remove(bullet);}}}@Overridepublic void draw(Graphics g) {// 绘制玩家飞机g.drawImage(Resources.playerImage, x, y, null);// 绘制子弹for (Bullet bullet : bullets) {bullet.draw(g);}}public void fire() {long currentTime = System.currentTimeMillis();if (currentTime - lastFireTime > FIRE_INTERVAL) {// 创建两颗子弹,分别从飞机两侧发射bullets.add(new Bullet(x + width/4, y, Bullet.Direction.UP));bullets.add(new Bullet(x + width*3/4, y, Bullet.Direction.UP));lastFireTime = currentTime;// 播放射击音效Resources.playShootSound();}}public void moveLeft(boolean moving) {this.movingLeft = moving;}public void moveRight(boolean moving) {this.movingRight = moving;}public void moveUp(boolean moving) {this.movingUp = moving;}public void moveDown(boolean moving) {this.movingDown = moving;}public List<Bullet> getBullets() {return bullets;}public int getLives() {return lives;}public void loseLife() {lives--;if (lives <= 0) {alive = false;}}public void reset() {x = 350 - width/2;y = 450;lives = DEFAULT_LIVES;alive = true;bullets.clear();}
}// Enemy.java
package com.aircraftgame.model;import com.aircraftgame.resource.Resources;import java.awt.*;
import java.util.Random;public class Enemy extends GameObject {private static final int DEFAULT_SPEED = 3;private static final int SCORE = 10;private int score;private Random random;public Enemy(int x, int y) {super(x, y, Resources.enemyImage.getWidth(), Resources.enemyImage.getHeight(), DEFAULT_SPEED);this.score = SCORE;this.random = new Random();}@Overridepublic void update() {y += speed;// 随机改变水平位置if (random.nextInt(100) < 5) {x += (random.nextInt(3) - 1) * speed;}// 检查是否超出屏幕if (y > 600) {alive = false;}}@Overridepublic void draw(Graphics g) {g.drawImage(Resources.enemyImage, x, y, null);}public int getScore() {return score;}public void explode() {// 播放爆炸音效Resources.playExplosionSound();}
}// Bullet.java
package com.aircraftgame.model;import com.aircraftgame.resource.Resources;import java.awt.*;public class Bullet extends GameObject {private static final int DEFAULT_SPEED = 10;public enum Direction {UP, DOWN}private Direction direction;public Bullet(int x, int y, Direction direction) {super(x, y, Resources.bulletImage.getWidth(), Resources.bulletImage.getHeight(), DEFAULT_SPEED);this.direction = direction;}@Overridepublic void update() {if (direction == Direction.UP) {y -= speed;} else {y += speed;}// 检查是否超出屏幕if (y < 0 || y > 600) {alive = false;}}@Overridepublic void draw(Graphics g) {g.drawImage(Resources.bulletImage, x, y, null);}public Direction getDirection() {return direction;}
}// Explosion.java
package com.aircraftgame.model;import com.aircraftgame.resource.Resources;import java.awt.*;public class Explosion extends GameObject {private static final int EXPLOSION_DURATION = 500; // 爆炸持续时间,毫秒private static final int DEFAULT_SPEED = 0;private long creationTime;public Explosion(int x, int y) {super(x, y, Resources.explosionImages[0].getWidth(), Resources.explosionImages[0].getHeight(), DEFAULT_SPEED);this.creationTime = System.currentTimeMillis();}@Overridepublic void update() {long currentTime = System.currentTimeMillis();if (currentTime - creationTime > EXPLOSION_DURATION) {alive = false;}}@Overridepublic void draw(Graphics g) {long currentTime = System.currentTimeMillis();int frame = (int) ((currentTime - creationTime) / 100); // 每100毫秒换一帧if (frame < Resources.explosionImages.length) {g.drawImage(Resources.explosionImages[frame], x, y, null);}}
}

3. 游戏控制器

// GameController.java
package com.aircraftgame.controller;import com.aircraftgame.model.*;
import com.aircraftgame.view.GamePanel;
import com.aircraftgame.resource.Resources;import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;public class GameController {private static final int ENEMY_SPAWN_INTERVAL = 1000; // 敌机生成间隔,毫秒private static final int LEVEL_UP_INTERVAL = 30000; // 关卡提升间隔,毫秒private GamePanel gamePanel;private Player player;private List<Enemy> enemies;private List<Bullet> enemyBullets;private List<Explosion> explosions;private int score;private int level;private long lastEnemySpawnTime;private long lastLevelUpTime;private boolean gameOver;private boolean paused;private Random random;public GameController() {player = new Player(350, 450);enemies = new ArrayList<>();enemyBullets = new ArrayList<>();explosions = new ArrayList<>();score = 0;level = 1;lastEnemySpawnTime = System.currentTimeMillis();lastLevelUpTime = System.currentTimeMillis();gameOver = false;paused = false;random = new Random();}public void initGame(GamePanel gamePanel) {this.gamePanel = gamePanel;// 添加键盘监听器gamePanel.addKeyListener(new KeyAdapter() {@Overridepublic void keyPressed(KeyEvent e) {handleKeyPress(e);}@Overridepublic void keyReleased(KeyEvent e) {handleKeyRelease(e);}});gamePanel.setFocusable(true);}public void startGame() {// 游戏主循环Thread gameThread = new Thread(() -> {while (true) {if (!paused && !gameOver) {updateGameState();checkCollisions();cleanUpObjects();}gamePanel.repaint();try {Thread.sleep(16); // 约60FPS} catch (InterruptedException e) {e.printStackTrace();}}});gameThread.start();}private void updateGameState() {// 更新玩家player.update();// 生成敌机long currentTime = System.currentTimeMillis();if (currentTime - lastEnemySpawnTime > ENEMY_SPAWN_INTERVAL / level) {spawnEnemy();lastEnemySpawnTime = currentTime;}// 提升关卡if (currentTime - lastLevelUpTime > LEVEL_UP_INTERVAL) {levelUp();lastLevelUpTime = currentTime;}// 更新敌机for (Enemy enemy : enemies) {enemy.update();// 敌机发射子弹if (random.nextInt(1000) < 2 + level) {fireEnemyBullet(enemy);}}// 更新敌机子弹for (Bullet bullet : enemyBullets) {bullet.update();}// 更新爆炸效果for (Explosion explosion : explosions) {explosion.update();}}private void spawnEnemy() {int x = random.nextInt(700 - Resources.enemyImage.getWidth());int y = -Resources.enemyImage.getHeight();enemies.add(new Enemy(x, y));}private void fireEnemyBullet(Enemy enemy) {int x = enemy.getX() + enemy.getWidth() / 2 - Resources.bulletImage.getWidth() / 2;int y = enemy.getY() + enemy.getHeight();Bullet bullet = new Bullet(x, y, Bullet.Direction.DOWN);enemyBullets.add(bullet);}private void checkCollisions() {// 检查玩家子弹与敌机的碰撞for (Bullet bullet : new ArrayList<>(player.getBullets())) {if (bullet.getDirection() == Bullet.Direction.UP) {for (Enemy enemy : new ArrayList<>(enemies)) {if (bullet.getBounds().intersects(enemy.getBounds())) {// 子弹击中敌机bullet.setAlive(false);enemy.setAlive(false);score += enemy.getScore();// 添加爆炸效果explosions.add(new Explosion(enemy.getX(), enemy.getY()));enemy.explode();}}}}// 检查敌机子弹与玩家的碰撞for (Bullet bullet : new ArrayList<>(enemyBullets)) {if (bullet.getDirection() == Bullet.Direction.DOWN && bullet.getBounds().intersects(player.getBounds())) {// 玩家被击中bullet.setAlive(false);player.loseLife();// 添加爆炸效果explosions.add(new Explosion(player.getX(), player.getY()));if (player.getLives() <= 0) {gameOver = true;Resources.playGameOverSound();} else {Resources.playHitSound();}}}// 检查敌机与玩家的碰撞for (Enemy enemy : new ArrayList<>(enemies)) {if (enemy.getBounds().intersects(player.getBounds())) {// 敌机与玩家相撞enemy.setAlive(false);player.loseLife();// 添加爆炸效果explosions.add(new Explosion(enemy.getX(), enemy.getY()));explosions.add(new Explosion(player.getX(), player.getY()));if (player.getLives() <= 0) {gameOver = true;Resources.playGameOverSound();} else {Resources.playHitSound();}}}}private void cleanUpObjects() {// 移除死亡的敌机enemies.removeIf(enemy -> !enemy.isAlive());// 移除死亡的子弹player.getBullets().removeIf(bullet -> !bullet.isAlive());enemyBullets.removeIf(bullet -> !bullet.isAlive());// 移除完成的爆炸效果explosions.removeIf(explosion -> !explosion.isAlive());}private void levelUp() {level++;Resources.playLevelUpSound();}private void handleKeyPress(KeyEvent e) {int keyCode = e.getKeyCode();switch (keyCode) {case KeyEvent.VK_LEFT:player.moveLeft(true);break;case KeyEvent.VK_RIGHT:player.moveRight(true);break;case KeyEvent.VK_UP:player.moveUp(true);break;case KeyEvent.VK_DOWN:player.moveDown(true);break;case KeyEvent.VK_SPACE:player.fire();break;case KeyEvent.VK_P:paused = !paused;break;case KeyEvent.VK_R:if (gameOver) {resetGame();}break;}}private void handleKeyRelease(KeyEvent e) {int keyCode = e.getKeyCode();switch (keyCode) {case KeyEvent.VK_LEFT:player.moveLeft(false);break;case KeyEvent.VK_RIGHT:player.moveRight(false);break;case KeyEvent.VK_UP:player.moveUp(false);break;case KeyEvent.VK_DOWN:player.moveDown(false);break;}}private void resetGame() {player.reset();enemies.clear();player.getBullets().clear();enemyBullets.clear();explosions.clear();score = 0;level = 1;gameOver = false;lastEnemySpawnTime = System.currentTimeMillis();lastLevelUpTime = System.currentTimeMillis();Resources.playBackgroundMusic();}public Player getPlayer() {return player;}public List<Enemy> getEnemies() {return enemies;}public List<Bullet> getEnemyBullets() {return enemyBullets;}public List<Explosion> getExplosions() {return explosions;}public int getScore() {return score;}public int getLevel() {return level;}public boolean isGameOver() {return gameOver;}public boolean isPaused() {return paused;}
}

4. 游戏视图

// GamePanel.java
package com.aircraftgame.view;import com.aircraftgame.controller.GameController;
import com.aircraftgame.model.Enemy;
import com.aircraftgame.model.Explosion;
import com.aircraftgame.model.Player;
import com.aircraftgame.resource.Resources;import javax.swing.*;
import java.awt.*;public class GamePanel extends JPanel {private GameController controller;public GamePanel(GameController controller) {this.controller = controller;setPreferredSize(new Dimension(700, 500));setBackground(Color.BLACK);}@Overrideprotected void paintComponent(Graphics g) {super.paintComponent(g);// 绘制背景g.drawImage(Resources.backgroundImage, 0, 0, null);// 绘制玩家Player player = controller.getPlayer();player.draw(g);// 绘制敌机for (Enemy enemy : controller.getEnemies()) {enemy.draw(g);}// 绘制敌机子弹for (var bullet : controller.getEnemyBullets()) {bullet.draw(g);}// 绘制爆炸效果for (Explosion explosion : controller.getExplosions()) {explosion.draw(g);}// 绘制游戏信息drawGameInfo(g);// 如果游戏暂停,显示暂停信息if (controller.isPaused()) {drawPauseScreen(g);}// 如果游戏结束,显示游戏结束信息if (controller.isGameOver()) {drawGameOverScreen(g);}}private void drawGameInfo(Graphics g) {g.setColor(Color.WHITE);g.setFont(new Font("Arial", Font.BOLD, 16));// 绘制分数g.drawString("分数: " + controller.getScore(), 20, 30);// 绘制关卡g.drawString("关卡: " + controller.getLevel(), 20, 60);// 绘制生命值g.drawString("生命值: " + controller.getPlayer().getLives(), 20, 90);// 绘制操作提示g.setFont(new Font("Arial", Font.PLAIN, 12));g.drawString("操作: ←→↑↓ 移动, 空格 射击, P 暂停, R 重新开始", 20, 480);}private void drawPauseScreen(Graphics g) {g.setColor(new Color(0, 0, 0, 150));g.fillRect(0, 0, getWidth(), getHeight());g.setColor(Color.WHITE);g.setFont(new Font("Arial", Font.BOLD, 48));g.drawString("游戏暂停", getWidth()/2 - 100, getHeight()/2);g.setFont(new Font("Arial", Font.PLAIN, 24));g.drawString("按 P 继续游戏", getWidth()/2 - 100, getHeight()/2 + 50);}private void drawGameOverScreen(Graphics g) {g.setColor(new Color(0, 0, 0, 150));g.fillRect(0, 0, getWidth(), getHeight());g.setColor(Color.RED);g.setFont(new Font("Arial", Font.BOLD, 48));g.drawString("游戏结束", getWidth()/2 - 100, getHeight()/2 - 30);g.setColor(Color.WHITE);g.setFont(new Font("Arial", Font.BOLD, 24));g.drawString("最终分数: " + controller.getScore(), getWidth()/2 - 80, getHeight()/2 + 20);g.setFont(new Font("Arial", Font.PLAIN, 24));g.drawString("按 R 重新开始", getWidth()/2 - 80, getHeight()/2 + 70);}
}// GameFrame.java
package com.aircraftgame.view;import com.aircraftgame.controller.GameController;import javax.swing.*;
import java.awt.*;public class GameFrame extends JFrame {public GameFrame(GameController controller) {setTitle("飞机射击游戏");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setResizable(false);// 添加游戏面板GamePanel gamePanel = new GamePanel(controller);add(gamePanel);// 显示窗口pack();setLocationRelativeTo(null);setVisible(true);}
}

5. 资源管理

// Resources.java
package com.aircraftgame.resource;import javax.sound.sampled.*;
import javax.swing.*;
import java.io.IOException;
import java.util.Objects;public class Resources {public static Image playerImage;public static Image enemyImage;public static Image bulletImage;public static Image backgroundImage;public static Image[] explosionImages;private static Clip backgroundMusic;private static Clip shootSound;private static Clip explosionSound;private static Clip hitSound;private static Clip levelUpSound;private static Clip gameOverSound;static {try {// 加载图片资源playerImage = new ImageIcon(Objects.requireNonNull(Resources.class.getResource("/images/player.png"))).getImage();enemyImage = new ImageIcon(Objects.requireNonNull(Resources.class.getResource("/images/enemy.png"))).getImage();bulletImage = new ImageIcon(Objects.requireNonNull(Resources.class.getResource("/images/bullet.png"))).getImage();backgroundImage = new ImageIcon(Objects.requireNonNull(Resources.class.getResource("/images/background.jpg"))).getImage();// 加载爆炸动画图片explosionImages = new Image[8];for (int i = 0; i < 8; i++) {explosionImages[i] = new ImageIcon(Objects.requireNonNull(Resources.class.getResource("/images/explosion" + (i+1) + ".png"))).getImage();}// 加载声音资源backgroundMusic = loadSound("/sounds/background.wav");shootSound = loadSound("/sounds/shoot.wav");explosionSound = loadSound("/sounds/explosion.wav");hitSound = loadSound("/sounds/hit.wav");levelUpSound = loadSound("/sounds/levelup.wav");gameOverSound = loadSound("/sounds/gameover.wav");// 设置背景音乐循环if (backgroundMusic != null) {backgroundMusic.loop(Clip.LOOP_CONTINUOUSLY);}} catch (Exception e) {e.printStackTrace();}}private static Clip loadSound(String path) {try {AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(Objects.requireNonNull(Resources.class.getResource(path)));Clip clip = AudioSystem.getClip();clip.open(audioInputStream);return clip;} catch (UnsupportedAudioFileException | IOException | LineUnavailableException e) {e.printStackTrace();return null;}}public static void playBackgroundMusic() {if (backgroundMusic != null && !backgroundMusic.isRunning()) {backgroundMusic.setFramePosition(0);backgroundMusic.start();}}public static void stopBackgroundMusic() {if (backgroundMusic != null && backgroundMusic.isRunning()) {backgroundMusic.stop();}}public static void playShootSound() {playSound(shootSound);}public static void playExplosionSound() {playSound(explosionSound);}public static void playHitSound() {playSound(hitSound);}public static void playLevelUpSound() {playSound(levelUpSound);}public static void playGameOverSound() {stopBackgroundMusic();playSound(gameOverSound);}private static void playSound(Clip clip) {if (clip != null) {if (clip.isRunning()) {clip.stop();}clip.setFramePosition(0);clip.start();}}
}

四、游戏功能模块

1. 玩家控制

  • 上下左右移动控制
  • 发射子弹攻击敌机
  • 生命值系统与碰撞检测

2. 敌人系统

  • 随机生成不同类型的敌机
  • 敌机自动向下移动并发射子弹
  • 敌机与玩家的碰撞检测

3. 游戏界面

  • 游戏主窗口与游戏区域
  • 游戏状态显示(分数、关卡、生命值)
  • 游戏暂停与结束界面

4. 特效与音效

  • 子弹发射与爆炸动画效果
  • 背景音乐与各种音效
  • 敌机被击中的视觉反馈

五、系统部署与测试

1. 环境要求

  • JDK 8+
  • 开发工具:IntelliJ IDEA 或 Eclipse

2. 部署步骤

  1. 下载并安装Java开发环境
  2. 使用IDE导入项目
  3. 确保资源文件(图片、声音)正确放置在resources目录下
  4. 编译并运行MainGame类

3. 测试用例

// GameControllerTest.java
package com.aircraftgame.controller;import com.aircraftgame.model.Enemy;
import com.aircraftgame.model.Player;
import org.junit.Before;
import org.junit.Test;import static org.junit.Assert.*;public class GameControllerTest {private GameController controller;@Beforepublic void setUp() {controller = new GameController();}@Testpublic void testInitialState() {Player player = controller.getPlayer();assertNotNull(player);assertEquals(3, player.getLives());assertFalse(controller.isGameOver());assertFalse(controller.isPaused());assertEquals(0, controller.getScore());assertEquals(1, controller.getLevel());}@Testpublic void testEnemySpawn() {// 模拟游戏运行一段时间long currentTime = System.currentTimeMillis();controller.updateGameState();// 由于敌机生成是随机的,这里只能验证敌机列表不为空try {Thread.sleep(2000); // 等待2秒,给敌机生成时间} catch (InterruptedException e) {e.printStackTrace();}controller.updateGameState();assertFalse(controller.getEnemies().isEmpty());}@Testpublic void testPlayerBulletCollision() {// 添加一个敌机Enemy enemy = new Enemy(350, 100);controller.getEnemies().add(enemy);// 玩家发射子弹Player player = controller.getPlayer();player.fire();// 模拟子弹移动到敌机位置player.getBullets().forEach(bullet -> bullet.setY(100));// 检查碰撞controller.checkCollisions();// 验证敌机被击中assertTrue(enemy.isAlive()); // 由于模拟的简化,可能无法检测到碰撞// 实际测试中,可能需要更复杂的碰撞检测验证}@Testpublic void testPlayerHit() {// 添加一个敌机子弹controller.getEnemyBullets().add(new com.aircraftgame.model.Bullet(350, 400, com.aircraftgame.model.Bullet.Direction.DOWN));// 检查碰撞controller.checkCollisions();// 验证玩家生命值减少assertEquals(2, controller.getPlayer().getLives());}@Testpublic void testGameOver() {// 让玩家失去所有生命值Player player = controller.getPlayer();player.loseLife();player.loseLife();player.loseLife();// 检查游戏是否结束assertTrue(controller.isGameOver());}@Testpublic void testLevelUp() {// 模拟游戏运行30秒,应该提升一个关卡long currentTime = System.currentTimeMillis();controller.lastLevelUpTime = currentTime - 30000; // 设置为30秒前controller.updateGameState();assertEquals(2, controller.getLevel());}
}

六、毕业设计文档框架

1. 论文框架

  1. 引言
  2. 相关技术综述
  3. 系统需求分析
  4. 系统设计
  5. 系统实现
  6. 系统测试
  7. 总结与展望

七、总结

本飞机射击游戏基于Java Swing开发,实现了经典飞机游戏的核心功能。通过本项目的开发,深入掌握了Java面向对象编程、图形界面设计、多线程编程和游戏开发的基本原理。游戏采用MVC架构设计,具有良好的可扩展性,可以方便地添加新功能和优化现有功能。

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

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

相关文章

通俗易懂linux环境变量

如果想要清楚的了解环境变量&#xff0c;我觉得我们需要先大致搞清楚一个简单的事——什么是会话&#xff1f; 会话大致是什么&#xff1f; 在这里我们的目的是更好的理解环境变量&#xff0c;所以适当讲解一下会话即可。通常我们都是用xshell连接远程服务器&#xff0c;都会打…

【补题】Codeforces Round 715 (Div. 2) C. The Sports Festival

题意&#xff1a;给你一个序列&#xff0c;你可以对它重新排序&#xff0c;然后使每个i&#xff0c;max(a0,a1……ai)-min(a0,a1……ai)最小。问答案是多少 思路&#xff1a; C. The Sports Festival&#xff08;区间DP&#xff09;-CSDN博客 区间dp&#xff0c;完全没想到…

ubuntu系统文件误删(/lib/x86_64-linux-gnu/libc.so.6)修复方案 [成功解决]

报错信息&#xff1a;libc.so.6: cannot open shared object file: No such file or directory&#xff1a; #ls, ln, sudo...命令都不能用 error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory重启后报错信息&…

SIFT算法详细原理与应用

SIFT算法详细原理与应用 1 SIFT算法由来 1.1 什么是 SIFT&#xff1f; SIFT&#xff0c;全称为 Scale-Invariant Feature Transform&#xff08;尺度不变特征变换&#xff09;&#xff0c;是一种用于图像特征检测和描述的经典算法。它通过提取图像中的局部关键点&#xff0c;…

NPOI操作EXCEL文件 ——CAD C# 二次开发

缺点:dll.版本容易加载错误。CAD加载插件时&#xff0c;没有加载所有类库。插件运行过程中用到某个类库&#xff0c;会从CAD的安装目录找&#xff0c;找不到就报错了。 【方案2】让CAD在加载过程中把类库加载到内存 【方案3】是发现缺少了哪个库&#xff0c;就用插件程序加载进…

Go字符串切片操作详解:str1[:index]

在Go语言中&#xff0c;return str1[:index] 是一个​​字符串切片操作​​&#xff0c;它截取字符串的一部分。让我们深入解析这个操作的含义和原理&#xff1a; 基本语法和含义 str1&#xff1a;原始字符串[:index]&#xff1a;切片操作符str1[:index]&#xff1a; ​​起始…

NVIDIA Dynamo:数据中心规模的分布式推理服务框架深度解析

NVIDIA Dynamo&#xff1a;数据中心规模的分布式推理服务框架深度解析 摘要 NVIDIA Dynamo是一个革命性的高吞吐量、低延迟推理框架&#xff0c;专为在多节点分布式环境中服务生成式AI和推理模型而设计。本文将深入分析Dynamo的架构设计、核心特性、代码实现以及实际应用示例&…

408第一季 - 数据结构 - 栈与队列的应用

括号匹配 用瞪眼法就可以知道的东西 栈在表达式求值运用 先简单看看就行&#xff0c;题目做了就理解了 AB是操作符,也是被狠狠加入后缀表达式了&#xff0c;然后后面就是*&#xff0c;只要优先级比栈顶运算符牛逼就放里面&#xff0c;很显然&#xff0c;*比牛逼 继续前进&#…

Ubuntu 下开机自动执行命令的方法

Ubuntu 下开机自动执行命令的方法&#xff08;使用 crontab&#xff09; 在日常使用 Ubuntu 或其他 Linux 系统时&#xff0c;我们常常需要让某些程序或脚本在系统启动后自动运行。例如&#xff1a;启动 Clash 代理、初始化服务、定时同步数据等。 本文将介绍一种简单且常用的…

jpackage 打包 jar包 为exe可执行程序

jpackage --input target/ --main-jar note.jar --runtime-image H:/Dpanbeifeng/apps/finalshell/jre --type app-image --dest output/ --main-class com.textmanager.Main --icon logo2.png --name 猫咪快笔记 jpackage 打包指令详细介绍 jpackage 概述 jpackage 是…

H5移动端性能优化策略(渲染优化+弱网优化+WebView优化)

一、渲染优化&#xff1a;首屏速度提升的核心​​ ​​1. 关键页面采用SSR或Native渲染​​ ​​适用场景​​&#xff1a;首页、列表页、详情页等强内容展示页面 ​​优化原理​​&#xff1a; ​​SSR&#xff08;服务端渲染&#xff09;​​&#xff1a;在服务端生成完整…

Matlab | matlab中的图像处理详解

MATLAB 图像处理详解 这里写目录标题图像处理 MATLAB 图像处理详解一、图像基础操作1. 图像读写与显示2. 图像信息获取3. 图像类型转换二、图像增强技术1. 对比度调整2. 去噪处理3. 锐化处理三、图像变换1. 几何变换2. 频域变换四、图像分割1. 阈值分割2. 边缘检测3. 区域分割五…

keysight是德科技N9923A网络分析仪

keysight是德科技N9923A网络分析仪 简  述&#xff1a;N9923A 是一款使用电池供电的便携式射频矢量网络分析仪&#xff0c;其中包括全 2 端口网络分析仪、电缆和天线测试仪、故障点距离测试仪、功率计以及 1 通道和 2 通道矢量电压表。 主要特性与技术指标 网络分析仪 * 2…

idea不识别lombok---实体类报没有getter方法

介绍 本篇文章&#xff0c;主要讲idea引入lombok后&#xff0c;在实体类中加注解Data&#xff0c;在项目启动的时候&#xff0c;编译不通过&#xff0c;报错xxx.java没有getXxxx&#xff08;&#xff09;方法。 原因有以下几种 1. idea没有开启lombok插件 2. 使用idea-2023…

本地主机部署开源企业云盘Seafile并实现外部访问

Seafile是一个开源、专业、可靠的云存储平台&#xff1b;解决文件集中存储、共享和跨平台访问等问题。这款软件功能强大&#xff0c;界面简洁、操作方便。 本文将详细的介绍如何利用本地主机部署 Seafile&#xff0c;并结合nat123&#xff0c;实现外网访问本地部署的 Seafile …

【从0-1的CSS】第1篇:CSS简介,选择器以及常用样式

文章目录 CSS简介CSS的语法规则选择器id选择器元素选择器类选择器选择器优先级 CSS注释 CSS常用设置样式颜色颜色名称(常用)RGB(常用)RGBA(常用)HEX(常用)HSLHSLA 背景background-colorbackground-imagebackground-size 字体text-aligntext-decorationtext-indentline-height 边…

SpringBoot+MySQL家政服务平台 设计开发

概述 基于SpringBootMySQL开发的家政服务平台完整项目&#xff0c;该系统实现了用户预约、服务管理、订单统计等核心功能&#xff0c;采用主流技术栈开发&#xff0c;代码规范且易于二次开发。 主要内容 系统功能架构 本系统采用前后端分离架构&#xff0c;前端提供用户交互…

3.1 HarmonyOS NEXT分布式数据管理实战:跨设备同步、端云协同与安全保护

HarmonyOS NEXT分布式数据管理实战&#xff1a;跨设备同步、端云协同与安全保护 在万物互联的时代&#xff0c;数据的跨设备流转与安全共享是全场景应用的核心需求。HarmonyOS NEXT通过分布式数据管理技术&#xff0c;实现了设备间数据的实时同步与端云协同&#xff0c;为开发…

高保真组件库:数字输入框

拖入一个文本框。 拖入一个矩形,作为整个数字输入框的边框,边框颜色为灰色DCDEE2,圆角半径为4。 拖入一个向上的箭头图标作为增加按钮,再拖入一个矩形,将向上箭头图标放入矩形内。矩形:18x15,边框颜色DCDEE2,边框左下可见,箭头图标:8x5,矩形置底,组合在一起命名”增…

【力扣链表篇】19.删除链表的倒数第N个节点

题目&#xff1a; 给你一个链表&#xff0c;删除链表的倒数第 n 个结点&#xff0c;并且返回链表的头结点。 示例 1&#xff1a; 输入&#xff1a;head [1,2,3,4,5], n 2 输出&#xff1a;[1,2,3,5]示例 2&#xff1a; 输入&#xff1a;head [1], n 1 输出&#xff1a;[]…