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
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/84100.shtml
英文地址,請注明出處:http://en.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;[]…