diff --git a/tankWar/src/Bullet.java b/tankWar/src/com/mashibing/tank/Bullet.java similarity index 94% rename from tankWar/src/Bullet.java rename to tankWar/src/com/mashibing/tank/Bullet.java index a70dc12..a0f8f5a 100644 --- a/tankWar/src/Bullet.java +++ b/tankWar/src/com/mashibing/tank/Bullet.java @@ -1,61 +1,63 @@ -import java.awt.*; - -/** - * @Description: 子弹 - * @Author: zhanxinlin - * @Date: 2022-09-27 23:10 - */ -public class Bullet { - private static final int SPEED = 10; - private static final int WIDTH = 20; - private static final int HEIGHT = 20; - - private int x; - private int y; - private FrameTank frameTank; - private Direction direction; - private boolean live = true; - - public Bullet(int x, int y, Direction direction, FrameTank frameTank) { - this.x = x; - this.y = y; - this.direction = direction; - this.frameTank = frameTank; - } - - public void paint(Graphics g) { - // 子弹超出界限,从子弹集合中移除 - if (!live) { - frameTank.bulletList.remove(this); - } - - Color color = g.getColor(); - g.setColor(Color.RED); - g.fillOval(x, y, WIDTH, HEIGHT); - g.setColor(color); - move(); - } - - private void move() { - // 定义坦克的移动特征 - switch (direction) { - case LEFT: - x -= SPEED; - break; - case UP: - y -= SPEED; - break; - case RIGHT: - x += SPEED; - break; - case DOWN: - y += SPEED; - break; - } - - // 子弹超出临界范围 - if (x < 0 || y < 0 || y > FrameTank.GAME_HEIGHT || x > FrameTank.GAME_WIDTH) { - live = false; - } - } -} +package com.mashibing.tank; + +import java.awt.*; + +/** + * @Description: 子弹 + * @Author: zhanxinlin + * @Date: 2022-09-27 23:10 + */ +public class Bullet { + private static final int SPEED = 10; + private static final int WIDTH = 20; + private static final int HEIGHT = 20; + + private int x; + private int y; + private FrameTank frameTank; + private Direction direction; + private boolean live = true; + + public Bullet(int x, int y, Direction direction, FrameTank frameTank) { + this.x = x; + this.y = y; + this.direction = direction; + this.frameTank = frameTank; + } + + public void paint(Graphics g) { + // 子弹超出界限,从子弹集合中移除 + if (!live) { + frameTank.bulletList.remove(this); + } + + Color color = g.getColor(); + g.setColor(Color.RED); + g.fillOval(x, y, WIDTH, HEIGHT); + g.setColor(color); + move(); + } + + private void move() { + // 定义坦克的移动特征 + switch (direction) { + case LEFT: + x -= SPEED; + break; + case UP: + y -= SPEED; + break; + case RIGHT: + x += SPEED; + break; + case DOWN: + y += SPEED; + break; + } + + // 子弹超出临界范围 + if (x < 0 || y < 0 || y > FrameTank.GAME_HEIGHT || x > FrameTank.GAME_WIDTH) { + live = false; + } + } +} diff --git a/tankWar/src/Direction.java b/tankWar/src/com/mashibing/tank/Direction.java similarity index 78% rename from tankWar/src/Direction.java rename to tankWar/src/com/mashibing/tank/Direction.java index 36176b0..b96ebb6 100644 --- a/tankWar/src/Direction.java +++ b/tankWar/src/com/mashibing/tank/Direction.java @@ -1,8 +1,10 @@ -/** - * @Description: 方向枚举 - * @Author: zhanxinlin - * @Date: 2022-09-27 22:21 - */ -public enum Direction { - LEFT, UP, RIGHT, DOWN -} +package com.mashibing.tank; + +/** + * @Description: 方向枚举 + * @Author: zhanxinlin + * @Date: 2022-09-27 22:21 + */ +public enum Direction { + LEFT, UP, RIGHT, DOWN +} diff --git a/tankWar/src/FrameTank.java b/tankWar/src/com/mashibing/tank/FrameTank.java similarity index 96% rename from tankWar/src/FrameTank.java rename to tankWar/src/com/mashibing/tank/FrameTank.java index ca5a7aa..d1034cc 100644 --- a/tankWar/src/FrameTank.java +++ b/tankWar/src/com/mashibing/tank/FrameTank.java @@ -1,161 +1,163 @@ -import java.awt.*; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.ArrayList; -import java.util.List; - -/** - * @Description: 坦克大战窗口 - * @Author: zhanxinlin - * @Date: 2022-09-27 21:34 - */ -public class FrameTank extends Frame{ - static final int GAME_WIDTH = 800; - static final int GAME_HEIGHT = 600; - - Tank myTank = new Tank(200 ,200, Direction.DOWN, this); - List bulletList = new ArrayList<>(); // 用集合来装子弹 - - // 构造方法 - public FrameTank() { - this.setSize(GAME_WIDTH, GAME_HEIGHT); - this.setResizable(false); // 窗口大小不可拉伸 - this.setVisible(true); // 窗口可见 - this.setTitle("tank war"); - - // 窗口监听器,点击"×",则关闭窗口,停止程序 - this.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - System.exit(0); - } - }); - - // 键盘按钮监听器 - this.addKeyListener(new MyKeyListener()); - } - - Image offScreenImage = null; - - /** - * 双缓冲解决窗口闪烁 - * - * @param g 画笔 - */ - @Override - public void update(Graphics g) { - if (offScreenImage == null) { - offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT); - } - Graphics gOffScreen = offScreenImage.getGraphics(); - Color c = gOffScreen.getColor(); - gOffScreen.setColor(Color.BLACK); - gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT); - gOffScreen.setColor(c); - paint(gOffScreen); - g.drawImage(offScreenImage, 0, 0, null); - } - - /** - * 画图方法,系统调用 - * - * @param g - */ - @Override - public void paint(Graphics g) { - Color color = g.getColor(); - g.setColor(Color.WHITE); - g.drawString("子弹的数量:" + bulletList.size(), 10, 60); - g.setColor(color); - - // 坦克把自己画出来 - myTank.paint(g); - - // 子弹把自己画出来 - for (int i = 0; i < bulletList.size(); i++) { - bulletList.get(i).paint(g); - } - } - - class MyKeyListener extends KeyAdapter { - boolean leftDirection = false; - boolean upDirection = false; - boolean rightDirection = false; - boolean downDirection = false; - - @Override - public void keyPressed(KeyEvent e) { - int key = e.getKeyCode(); - switch (key) { - case KeyEvent.VK_LEFT: - leftDirection = true; - break; - case KeyEvent.VK_UP: - upDirection = true; - break; - case KeyEvent.VK_RIGHT: - rightDirection = true; - break; - case KeyEvent.VK_DOWN: - downDirection = true; - break; - case KeyEvent.VK_CONTROL: - myTank.fire(); - break; - default: - break; - } - - setMainTankDirection(); - } - - @Override - public void keyReleased(KeyEvent e) { - int key = e.getKeyCode(); - switch (key) { - case KeyEvent.VK_LEFT: - leftDirection = false; - break; - case KeyEvent.VK_UP: - upDirection = false; - break; - case KeyEvent.VK_RIGHT: - rightDirection = false; - break; - case KeyEvent.VK_DOWN: - downDirection = false; - break; - default: - break; - } - - setMainTankDirection(); - } - - /** - * 改变坦克的方向 - */ - private void setMainTankDirection() { - if (!leftDirection && !upDirection && !downDirection && !rightDirection) { // 没有按方向键,静止不动 - myTank.setMoving(false); - } else { // 按了方向键 - myTank.setMoving(true); - - if (leftDirection) { - myTank.setDirection(Direction.LEFT); - } - if (rightDirection) { - myTank.setDirection(Direction.RIGHT); - } - if (upDirection) { - myTank.setDirection(Direction.UP); - } - if (downDirection) { - myTank.setDirection(Direction.DOWN); - } - } - } - } -} +package com.mashibing.tank; + +import java.awt.*; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.List; + +/** + * @Description: 坦克大战窗口 + * @Author: zhanxinlin + * @Date: 2022-09-27 21:34 + */ +public class FrameTank extends Frame{ + static final int GAME_WIDTH = 800; + static final int GAME_HEIGHT = 600; + + Tank myTank = new Tank(200 ,200, Direction.DOWN, this); + List bulletList = new ArrayList<>(); // 用集合来装子弹 + + // 构造方法 + public FrameTank() { + this.setSize(GAME_WIDTH, GAME_HEIGHT); + this.setResizable(false); // 窗口大小不可拉伸 + this.setVisible(true); // 窗口可见 + this.setTitle("tank war"); + + // 窗口监听器,点击"×",则关闭窗口,停止程序 + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + // 键盘按钮监听器 + this.addKeyListener(new MyKeyListener()); + } + + Image offScreenImage = null; + + /** + * 双缓冲解决窗口闪烁 + * + * @param g 画笔 + */ + @Override + public void update(Graphics g) { + if (offScreenImage == null) { + offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT); + } + Graphics gOffScreen = offScreenImage.getGraphics(); + Color c = gOffScreen.getColor(); + gOffScreen.setColor(Color.BLACK); + gOffScreen.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT); + gOffScreen.setColor(c); + paint(gOffScreen); + g.drawImage(offScreenImage, 0, 0, null); + } + + /** + * 画图方法,系统调用 + * + * @param g + */ + @Override + public void paint(Graphics g) { + Color color = g.getColor(); + g.setColor(Color.WHITE); + g.drawString("子弹的数量:" + bulletList.size(), 10, 60); + g.setColor(color); + + // 坦克把自己画出来 + myTank.paint(g); + + // 子弹把自己画出来 + for (int i = 0; i < bulletList.size(); i++) { + bulletList.get(i).paint(g); + } + } + + class MyKeyListener extends KeyAdapter { + boolean leftDirection = false; + boolean upDirection = false; + boolean rightDirection = false; + boolean downDirection = false; + + @Override + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + switch (key) { + case KeyEvent.VK_LEFT: + leftDirection = true; + break; + case KeyEvent.VK_UP: + upDirection = true; + break; + case KeyEvent.VK_RIGHT: + rightDirection = true; + break; + case KeyEvent.VK_DOWN: + downDirection = true; + break; + case KeyEvent.VK_CONTROL: + myTank.fire(); + break; + default: + break; + } + + setMainTankDirection(); + } + + @Override + public void keyReleased(KeyEvent e) { + int key = e.getKeyCode(); + switch (key) { + case KeyEvent.VK_LEFT: + leftDirection = false; + break; + case KeyEvent.VK_UP: + upDirection = false; + break; + case KeyEvent.VK_RIGHT: + rightDirection = false; + break; + case KeyEvent.VK_DOWN: + downDirection = false; + break; + default: + break; + } + + setMainTankDirection(); + } + + /** + * 改变坦克的方向 + */ + private void setMainTankDirection() { + if (!leftDirection && !upDirection && !downDirection && !rightDirection) { // 没有按方向键,静止不动 + myTank.setMoving(false); + } else { // 按了方向键 + myTank.setMoving(true); + + if (leftDirection) { + myTank.setDirection(Direction.LEFT); + } + if (rightDirection) { + myTank.setDirection(Direction.RIGHT); + } + if (upDirection) { + myTank.setDirection(Direction.UP); + } + if (downDirection) { + myTank.setDirection(Direction.DOWN); + } + } + } + } +} diff --git a/tankWar/src/Main.java b/tankWar/src/com/mashibing/tank/Main.java similarity index 89% rename from tankWar/src/Main.java rename to tankWar/src/com/mashibing/tank/Main.java index dcc431c..4e8e0be 100644 --- a/tankWar/src/Main.java +++ b/tankWar/src/com/mashibing/tank/Main.java @@ -1,15 +1,17 @@ -/** - * @Description: 程序启动入口 - * @Author: zhanxinlin - * @Date: 2022-09-27 22:00 - */ -public class Main { - public static void main(String[] args) throws InterruptedException { - FrameTank frameTank = new FrameTank(); - - while (true) { - Thread.sleep(50); - frameTank.repaint(); // 重画窗口,重新调用paint方法 - } - } -} +package com.mashibing.tank; + +/** + * @Description: 程序启动入口 + * @Author: zhanxinlin + * @Date: 2022-09-27 22:00 + */ +public class Main { + public static void main(String[] args) throws InterruptedException { + FrameTank frameTank = new FrameTank(); + + while (true) { + Thread.sleep(50); + frameTank.repaint(); // 重画窗口,重新调用paint方法 + } + } +} diff --git a/tankWar/src/com/mashibing/tank/ResourceImageRead.java b/tankWar/src/com/mashibing/tank/ResourceImageRead.java new file mode 100644 index 0000000..c80ee01 --- /dev/null +++ b/tankWar/src/com/mashibing/tank/ResourceImageRead.java @@ -0,0 +1,29 @@ +package com.mashibing.tank; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; + +/** + * @Description: 读取图片资源类 + * @Author: zhanxinlin + * @Date: 2022-09-28 23:14 + */ +public class ResourceImageRead { + public static BufferedImage TANK_LEFT; + public static BufferedImage TANK_UP; + public static BufferedImage TANK_RIGHT; + public static BufferedImage TANK_DOWN; + + // 当ResourceImageRead类加载时,静态代码块执行,直接初始化 + static { + try { + TANK_LEFT = ImageIO.read(ResourceImageRead.class.getClassLoader().getResourceAsStream("images/tankL.gif")); + TANK_UP = ImageIO.read(ResourceImageRead.class.getClassLoader().getResourceAsStream("images/tankU.gif")); + TANK_RIGHT = ImageIO.read(ResourceImageRead.class.getClassLoader().getResourceAsStream("images/tankR.gif")); + TANK_DOWN = ImageIO.read(ResourceImageRead.class.getClassLoader().getResourceAsStream("images/tankD.gif")); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/tankWar/src/Tank.java b/tankWar/src/com/mashibing/tank/Tank.java similarity index 72% rename from tankWar/src/Tank.java rename to tankWar/src/com/mashibing/tank/Tank.java index a53947e..f73b03f 100644 --- a/tankWar/src/Tank.java +++ b/tankWar/src/com/mashibing/tank/Tank.java @@ -1,86 +1,101 @@ -import java.awt.*; - -/** - * @Description: 坦克类 - * @Author: zhanxinlin - * @Date: 2022-09-27 22:49 - */ -public class Tank { - private static final int SPEED = 5; - private int x; - private int y; - private Direction direction; - private boolean moving = false; - private FrameTank frameTank = null; - - public Tank(int x, int y, Direction direction, FrameTank frameTank) { - this.x = x; - this.y = y; - this.direction = direction; - this.frameTank = frameTank; - } - - /** - * tank把自己画出来 - * - * @param g 画笔 - */ - public void paint(Graphics g) { - Color color = g.getColor(); - g.setColor(Color.GREEN); - g.fillRect(x, y, 50, 50); - g.setColor(color); - move(); - } - - /** - * 坦克移动方法 - */ - private void move() { - if (!moving) { - return; - } - - // 定义坦克的移动特征 - switch (direction) { - case LEFT: - x -= SPEED; - break; - case UP: - y -= SPEED; - break; - case RIGHT: - x += SPEED; - break; - case DOWN: - y += SPEED; - break; - } - } - - /** - * 坦克开火方法 - * 难点:如何将坦克对象new出来的子弹对象bullet传递到FrameTank对象的子弹对象bullet中 - * 解决:坦克对象要持有FrameTank对象的引用 - */ - public void fire() { - // 将子弹加入子弹集合 - frameTank.bulletList.add(new Bullet(this.x, this.y, this.direction, this.frameTank)); - } - - public Direction getDirection() { - return direction; - } - - public void setDirection(Direction direction) { - this.direction = direction; - } - - public boolean isMoving() { - return moving; - } - - public void setMoving(boolean moving) { - this.moving = moving; - } -} +package com.mashibing.tank; + +import java.awt.*; + +/** + * @Description: 坦克类 + * @Author: zhanxinlin + * @Date: 2022-09-27 22:49 + */ +public class Tank { + private static final int SPEED = 5; + private int x; + private int y; + private Direction direction; + private boolean moving = false; + private FrameTank frameTank = null; + + public Tank(int x, int y, Direction direction, FrameTank frameTank) { + this.x = x; + this.y = y; + this.direction = direction; + this.frameTank = frameTank; + } + + /** + * tank把自己画出来 + * + * @param g 画笔 + */ + public void paint(Graphics g) { + // 画出坦克前后左右移动的图片 + switch (direction) { + case LEFT: + g.drawImage(ResourceImageRead.TANK_LEFT, x, y, null); + break; + case UP: + g.drawImage(ResourceImageRead.TANK_UP, x, y, null); + break; + case RIGHT: + g.drawImage(ResourceImageRead.TANK_RIGHT, x, y, null); + break; + case DOWN: + g.drawImage(ResourceImageRead.TANK_DOWN, x, y, null); + break; + } + + // 坦克移动 + move(); + } + + /** + * 坦克移动方法 + */ + private void move() { + if (!moving) { + return; + } + + // 定义坦克的移动特征 + switch (direction) { + case LEFT: + x -= SPEED; + break; + case UP: + y -= SPEED; + break; + case RIGHT: + x += SPEED; + break; + case DOWN: + y += SPEED; + break; + } + } + + /** + * 坦克开火方法 + * 难点:如何将坦克对象new出来的子弹对象bullet传递到FrameTank对象的子弹对象bullet中 + * 解决:坦克对象要持有FrameTank对象的引用 + */ + public void fire() { + // 将子弹加入子弹集合 + frameTank.bulletList.add(new Bullet(this.x, this.y, this.direction, this.frameTank)); + } + + public Direction getDirection() { + return direction; + } + + public void setDirection(Direction direction) { + this.direction = direction; + } + + public boolean isMoving() { + return moving; + } + + public void setMoving(boolean moving) { + this.moving = moving; + } +} diff --git a/tankWar/src/images/0.gif b/tankWar/src/images/0.gif new file mode 100644 index 0000000..79c5218 Binary files /dev/null and b/tankWar/src/images/0.gif differ diff --git a/tankWar/src/images/1.gif b/tankWar/src/images/1.gif new file mode 100644 index 0000000..eface51 Binary files /dev/null and b/tankWar/src/images/1.gif differ diff --git a/tankWar/src/images/10.gif b/tankWar/src/images/10.gif new file mode 100644 index 0000000..ffd49b8 Binary files /dev/null and b/tankWar/src/images/10.gif differ diff --git a/tankWar/src/images/2.gif b/tankWar/src/images/2.gif new file mode 100644 index 0000000..b88b47e Binary files /dev/null and b/tankWar/src/images/2.gif differ diff --git a/tankWar/src/images/3.gif b/tankWar/src/images/3.gif new file mode 100644 index 0000000..88e81e8 Binary files /dev/null and b/tankWar/src/images/3.gif differ diff --git a/tankWar/src/images/4.gif b/tankWar/src/images/4.gif new file mode 100644 index 0000000..4cc91ab Binary files /dev/null and b/tankWar/src/images/4.gif differ diff --git a/tankWar/src/images/5.gif b/tankWar/src/images/5.gif new file mode 100644 index 0000000..c1cc5d7 Binary files /dev/null and b/tankWar/src/images/5.gif differ diff --git a/tankWar/src/images/6.gif b/tankWar/src/images/6.gif new file mode 100644 index 0000000..4f43fc7 Binary files /dev/null and b/tankWar/src/images/6.gif differ diff --git a/tankWar/src/images/7.gif b/tankWar/src/images/7.gif new file mode 100644 index 0000000..20358ba Binary files /dev/null and b/tankWar/src/images/7.gif differ diff --git a/tankWar/src/images/8.gif b/tankWar/src/images/8.gif new file mode 100644 index 0000000..ae410c9 Binary files /dev/null and b/tankWar/src/images/8.gif differ diff --git a/tankWar/src/images/9.gif b/tankWar/src/images/9.gif new file mode 100644 index 0000000..11efedd Binary files /dev/null and b/tankWar/src/images/9.gif differ diff --git a/tankWar/src/images/BadTank1.png b/tankWar/src/images/BadTank1.png new file mode 100644 index 0000000..d661b80 Binary files /dev/null and b/tankWar/src/images/BadTank1.png differ diff --git a/tankWar/src/images/BadTank2.png b/tankWar/src/images/BadTank2.png new file mode 100644 index 0000000..c2a2b01 Binary files /dev/null and b/tankWar/src/images/BadTank2.png differ diff --git a/tankWar/src/images/GoodTank1.png b/tankWar/src/images/GoodTank1.png new file mode 100644 index 0000000..8afb8b0 Binary files /dev/null and b/tankWar/src/images/GoodTank1.png differ diff --git a/tankWar/src/images/GoodTank2.png b/tankWar/src/images/GoodTank2.png new file mode 100644 index 0000000..a1b131a Binary files /dev/null and b/tankWar/src/images/GoodTank2.png differ diff --git a/tankWar/src/images/bulletD.gif b/tankWar/src/images/bulletD.gif new file mode 100644 index 0000000..be33e5f Binary files /dev/null and b/tankWar/src/images/bulletD.gif differ diff --git a/tankWar/src/images/bulletL.gif b/tankWar/src/images/bulletL.gif new file mode 100644 index 0000000..1ab986a Binary files /dev/null and b/tankWar/src/images/bulletL.gif differ diff --git a/tankWar/src/images/bulletR.gif b/tankWar/src/images/bulletR.gif new file mode 100644 index 0000000..514e982 Binary files /dev/null and b/tankWar/src/images/bulletR.gif differ diff --git a/tankWar/src/images/bulletU.gif b/tankWar/src/images/bulletU.gif new file mode 100644 index 0000000..274c570 Binary files /dev/null and b/tankWar/src/images/bulletU.gif differ diff --git a/tankWar/src/images/bulletU.png b/tankWar/src/images/bulletU.png new file mode 100644 index 0000000..f6f7203 Binary files /dev/null and b/tankWar/src/images/bulletU.png differ diff --git a/tankWar/src/images/e1.gif b/tankWar/src/images/e1.gif new file mode 100644 index 0000000..4ba0e92 Binary files /dev/null and b/tankWar/src/images/e1.gif differ diff --git a/tankWar/src/images/e10.gif b/tankWar/src/images/e10.gif new file mode 100644 index 0000000..5667574 Binary files /dev/null and b/tankWar/src/images/e10.gif differ diff --git a/tankWar/src/images/e11.gif b/tankWar/src/images/e11.gif new file mode 100644 index 0000000..7d6747c Binary files /dev/null and b/tankWar/src/images/e11.gif differ diff --git a/tankWar/src/images/e12.gif b/tankWar/src/images/e12.gif new file mode 100644 index 0000000..97f85df Binary files /dev/null and b/tankWar/src/images/e12.gif differ diff --git a/tankWar/src/images/e13.gif b/tankWar/src/images/e13.gif new file mode 100644 index 0000000..473cab1 Binary files /dev/null and b/tankWar/src/images/e13.gif differ diff --git a/tankWar/src/images/e14.gif b/tankWar/src/images/e14.gif new file mode 100644 index 0000000..676fa2a Binary files /dev/null and b/tankWar/src/images/e14.gif differ diff --git a/tankWar/src/images/e15.gif b/tankWar/src/images/e15.gif new file mode 100644 index 0000000..d3795f8 Binary files /dev/null and b/tankWar/src/images/e15.gif differ diff --git a/tankWar/src/images/e16.gif b/tankWar/src/images/e16.gif new file mode 100644 index 0000000..4a913c3 Binary files /dev/null and b/tankWar/src/images/e16.gif differ diff --git a/tankWar/src/images/e2.gif b/tankWar/src/images/e2.gif new file mode 100644 index 0000000..f22cbb8 Binary files /dev/null and b/tankWar/src/images/e2.gif differ diff --git a/tankWar/src/images/e3.gif b/tankWar/src/images/e3.gif new file mode 100644 index 0000000..58c1e2a Binary files /dev/null and b/tankWar/src/images/e3.gif differ diff --git a/tankWar/src/images/e4.gif b/tankWar/src/images/e4.gif new file mode 100644 index 0000000..981e9e2 Binary files /dev/null and b/tankWar/src/images/e4.gif differ diff --git a/tankWar/src/images/e5.gif b/tankWar/src/images/e5.gif new file mode 100644 index 0000000..fc93522 Binary files /dev/null and b/tankWar/src/images/e5.gif differ diff --git a/tankWar/src/images/e6.gif b/tankWar/src/images/e6.gif new file mode 100644 index 0000000..1bba69a Binary files /dev/null and b/tankWar/src/images/e6.gif differ diff --git a/tankWar/src/images/e7.gif b/tankWar/src/images/e7.gif new file mode 100644 index 0000000..9719061 Binary files /dev/null and b/tankWar/src/images/e7.gif differ diff --git a/tankWar/src/images/e8.gif b/tankWar/src/images/e8.gif new file mode 100644 index 0000000..710d7ea Binary files /dev/null and b/tankWar/src/images/e8.gif differ diff --git a/tankWar/src/images/e9.gif b/tankWar/src/images/e9.gif new file mode 100644 index 0000000..0535c88 Binary files /dev/null and b/tankWar/src/images/e9.gif differ diff --git a/tankWar/src/images/missileLD.gif b/tankWar/src/images/missileLD.gif new file mode 100644 index 0000000..4a1d311 Binary files /dev/null and b/tankWar/src/images/missileLD.gif differ diff --git a/tankWar/src/images/missileLU.gif b/tankWar/src/images/missileLU.gif new file mode 100644 index 0000000..e1fb913 Binary files /dev/null and b/tankWar/src/images/missileLU.gif differ diff --git a/tankWar/src/images/missileRD.gif b/tankWar/src/images/missileRD.gif new file mode 100644 index 0000000..d58cc9c Binary files /dev/null and b/tankWar/src/images/missileRD.gif differ diff --git a/tankWar/src/images/missileRU.gif b/tankWar/src/images/missileRU.gif new file mode 100644 index 0000000..1eed195 Binary files /dev/null and b/tankWar/src/images/missileRU.gif differ diff --git a/tankWar/src/images/square0.jpg b/tankWar/src/images/square0.jpg new file mode 100644 index 0000000..5b80bf0 Binary files /dev/null and b/tankWar/src/images/square0.jpg differ diff --git a/tankWar/src/images/square1.jpg b/tankWar/src/images/square1.jpg new file mode 100644 index 0000000..324341d Binary files /dev/null and b/tankWar/src/images/square1.jpg differ diff --git a/tankWar/src/images/square2.jpg b/tankWar/src/images/square2.jpg new file mode 100644 index 0000000..be66ad8 Binary files /dev/null and b/tankWar/src/images/square2.jpg differ diff --git a/tankWar/src/images/square3.jpg b/tankWar/src/images/square3.jpg new file mode 100644 index 0000000..109430b Binary files /dev/null and b/tankWar/src/images/square3.jpg differ diff --git a/tankWar/src/images/square4.jpg b/tankWar/src/images/square4.jpg new file mode 100644 index 0000000..ba00d68 Binary files /dev/null and b/tankWar/src/images/square4.jpg differ diff --git a/tankWar/src/images/square5.jpg b/tankWar/src/images/square5.jpg new file mode 100644 index 0000000..56198aa Binary files /dev/null and b/tankWar/src/images/square5.jpg differ diff --git a/tankWar/src/images/square6.jpg b/tankWar/src/images/square6.jpg new file mode 100644 index 0000000..2923b9a Binary files /dev/null and b/tankWar/src/images/square6.jpg differ diff --git a/tankWar/src/images/tank.png b/tankWar/src/images/tank.png new file mode 100644 index 0000000..54c82ba Binary files /dev/null and b/tankWar/src/images/tank.png differ diff --git a/tankWar/src/images/tankD.gif b/tankWar/src/images/tankD.gif new file mode 100644 index 0000000..4c29adf Binary files /dev/null and b/tankWar/src/images/tankD.gif differ diff --git a/tankWar/src/images/tankL.gif b/tankWar/src/images/tankL.gif new file mode 100644 index 0000000..af51e88 Binary files /dev/null and b/tankWar/src/images/tankL.gif differ diff --git a/tankWar/src/images/tankLD.gif b/tankWar/src/images/tankLD.gif new file mode 100644 index 0000000..2f6bca7 Binary files /dev/null and b/tankWar/src/images/tankLD.gif differ diff --git a/tankWar/src/images/tankLU.gif b/tankWar/src/images/tankLU.gif new file mode 100644 index 0000000..1e1a514 Binary files /dev/null and b/tankWar/src/images/tankLU.gif differ diff --git a/tankWar/src/images/tankR.gif b/tankWar/src/images/tankR.gif new file mode 100644 index 0000000..a83f583 Binary files /dev/null and b/tankWar/src/images/tankR.gif differ diff --git a/tankWar/src/images/tankRD.gif b/tankWar/src/images/tankRD.gif new file mode 100644 index 0000000..60e2e81 Binary files /dev/null and b/tankWar/src/images/tankRD.gif differ diff --git a/tankWar/src/images/tankRU.gif b/tankWar/src/images/tankRU.gif new file mode 100644 index 0000000..d66ef25 Binary files /dev/null and b/tankWar/src/images/tankRU.gif differ diff --git a/tankWar/src/images/tankU.gif b/tankWar/src/images/tankU.gif new file mode 100644 index 0000000..8825a23 Binary files /dev/null and b/tankWar/src/images/tankU.gif differ diff --git a/tankWar/src/test/ImageTest.java b/tankWar/src/test/ImageTest.java new file mode 100644 index 0000000..e4549fd --- /dev/null +++ b/tankWar/src/test/ImageTest.java @@ -0,0 +1,33 @@ +package test; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.jupiter.api.Test; + +/** + * 读取图片测试类 + */ +class ImageTest { + + @Test + void test() { + + try { + // 读取图片路径写死,不推荐 +// BufferedImage image = ImageIO.read(new File("C:/work/javaprojects/Tank_60/src/images/bulletD.gif")); +// assertNotNull(image); + + BufferedImage image2 = ImageIO.read(ImageTest.class.getClassLoader().getResourceAsStream("images/bulletD.gif")); + assertNotNull(image2); + } catch (IOException e) { + e.printStackTrace(); + } + } + +}