diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..35507b8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..17155c5 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..f84ae45 --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..d9de6f7 --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_aop_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_aop_5_3_23.xml new file mode 100644 index 0000000..73db827 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_aop_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_beans_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_beans_5_3_23.xml new file mode 100644 index 0000000..c1a1fdc --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_beans_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_context_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_context_5_3_23.xml new file mode 100644 index 0000000..c4590c3 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_context_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_core_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_core_5_3_23.xml new file mode 100644 index 0000000..8e72491 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_core_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_expression_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_expression_5_3_23.xml new file mode 100644 index 0000000..1e8c1a7 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_expression_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_spring_jcl_5_3_23.xml b/.idea/libraries/Maven__org_springframework_spring_jcl_5_3_23.xml new file mode 100644 index 0000000..4036467 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_spring_jcl_5_3_23.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4361200 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..1c6fb35 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/0/8/081d67b31c95c91f6926f605dfc94fdd2bada262 b/.idea/sonarlint/issuestore/0/8/081d67b31c95c91f6926f605dfc94fdd2bada262 new file mode 100644 index 0000000..0044852 --- /dev/null +++ b/.idea/sonarlint/issuestore/0/8/081d67b31c95c91f6926f605dfc94fdd2bada262 @@ -0,0 +1,30 @@ + +t java:S115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.( +t java:S115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(γ +< +java:S1170"!Make this final field static too.( +Q java:S125""5Rename "b" which hides the field declared at line 15.(_ +Q java:S125B" +java:S1604"(Make this anonymous inner class a lambda(î \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/6/9/69fcf7cf0cb84aa5f9c25dd41d8b89bcf868840a b/.idea/sonarlint/issuestore/6/9/69fcf7cf0cb84aa5f9c25dd41d8b89bcf868840a new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/7/0/70f82ce88ac6b54afd6eed03fe6951084561b5c5 b/.idea/sonarlint/issuestore/7/0/70f82ce88ac6b54afd6eed03fe6951084561b5c5 new file mode 100644 index 0000000..0acf512 --- /dev/null +++ b/.idea/sonarlint/issuestore/7/0/70f82ce88ac6b54afd6eed03fe6951084561b5c5 @@ -0,0 +1,40 @@ + +t java:S115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.( +t java:S115"ZRename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.(γ +K +java:S2387")"x" is the name of a field in "BaseTank".(߯80 +K +java:S2387")"y" is the name of a field in "BaseTank".(߯80 +O +java:S2387"-"group" is the name of a field in "BaseTank".(80 +< +java:S1170"!Make this final field static too.( +: +java:S1659"Declare "y" on a separate line.(߯ +W +java:S1161":Add the "@Override" annotation above this method signature(ǽ80 +\ +java:S1161!":Add the "@Override" annotation above this method signature(Ϭ80 +] java:S125&" java:S1084")Either remove or fill this block of code.( +W +java:S1161B":Add the "@Override" annotation above this method signature(80 +Q java:S1259" +java:S1604"(Make this anonymous inner class a lambda(î \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/c/d/cd8bb0d273a44e56af2c725281536ed379107cc0 b/.idea/sonarlint/issuestore/c/d/cd8bb0d273a44e56af2c725281536ed379107cc0 new file mode 100644 index 0000000..9543cde --- /dev/null +++ b/.idea/sonarlint/issuestore/c/d/cd8bb0d273a44e56af2c725281536ed379107cc0 @@ -0,0 +1,28 @@ + +7 java:S131_""Add a default case to this switch.(Ӂ +S java:S106t"9Replace this use of System.out or System.err by a logger.( +7 java:S131u""Add a default case to this switch.(Ӂ +^ +java:S1126"BReplace this if-then-else statement by a single method invocation.(Ҧ +t +java:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").( +t +java:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").( +o +java:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").( + +java:S1319"eThe type of "tanks" should be an interface such as "List" rather than the implementation "ArrayList".(8ٱ0 + +java:S1319"gThe type of "bullets" should be an interface such as "List" rather than the implementation "ArrayList".(80 + +java:S1319"hThe type of "explodes" should be an interface such as "List" rather than the implementation "ArrayList".(80 +s +java:S1104"QMake tanks a static final constant or non-public and provide accessors if needed.(80 +t +java:S1104"RMake myTank a static final constant or non-public and provide accessors if needed.(80 +u +java:S1104"SMake bullets a static final constant or non-public and provide accessors if needed.(80 +q +java:S1104"TMake explodes a static final constant or non-public and provide accessors if needed.(8ٱ0 +p +java:S1104"NMake gf a static final constant or non-public and provide accessors if needed.(ʴ80 \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/e/2/e2f699d7ece4648d65d8f55bbb53b4c1a97a0134 b/.idea/sonarlint/issuestore/e/2/e2f699d7ece4648d65d8f55bbb53b4c1a97a0134 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/e/3/e33fa438c138d070344c0d8500f75aa75f823e55 b/.idea/sonarlint/issuestore/e/3/e33fa438c138d070344c0d8500f75aa75f823e55 new file mode 100644 index 0000000..acf329c --- /dev/null +++ b/.idea/sonarlint/issuestore/e/3/e33fa438c138d070344c0d8500f75aa75f823e55 @@ -0,0 +1,63 @@ + +a +java:S1659"FDeclare "goodTankR" and all following declarations on a separate line.(Ǭ +` +java:S1659"EDeclare "badTankR" and all following declarations on a separate line.(  +Z +java:S1659"DDeclare "bulletR" and all following declarations on a separate line.( +8 +java:S2386"Make this member "protected".( +\ +java:S1118":Add a private constructor to hide the implicit public one.(Ϧ8ʕ0 +p +java:S1104"UMake goodTankL a static final constant or non-public and provide accessors if needed.(Ǭ +p +java:S1104"UMake goodTankR a static final constant or non-public and provide accessors if needed.(Ǭ +p +java:S1104"UMake goodTankU a static final constant or non-public and provide accessors if needed.(Ǭ +p +java:S1104"UMake goodTankD a static final constant or non-public and provide accessors if needed.(Ǭ +o +java:S1104"TMake badTankL a static final constant or non-public and provide accessors if needed.(  +o +java:S1104"TMake badTankR a static final constant or non-public and provide accessors if needed.(  +o +java:S1104"TMake badTankU a static final constant or non-public and provide accessors if needed.(  +o +java:S1104"TMake badTankD a static final constant or non-public and provide accessors if needed.(  +i +java:S1104"SMake bulletL a static final constant or non-public and provide accessors if needed.( +i +java:S1104"SMake bulletR a static final constant or non-public and provide accessors if needed.( +i +java:S1104"SMake bulletU a static final constant or non-public and provide accessors if needed.( +i +java:S1104"SMake bulletD a static final constant or non-public and provide accessors if needed.( +o +java:S1104"TMake explodes a static final constant or non-public and provide accessors if needed.( +J +java:S1444"/Make this "public static goodTankL" field final(Ǭ +J +java:S1444"/Make this "public static goodTankR" field final(Ǭ +J +java:S1444"/Make this "public static goodTankU" field final(Ǭ +J +java:S1444"/Make this "public static goodTankD" field final(Ǭ +I +java:S1444".Make this "public static badTankL" field final(  +I +java:S1444".Make this "public static badTankR" field final(  +I +java:S1444".Make this "public static badTankU" field final(  +I +java:S1444".Make this "public static badTankD" field final(  +C +java:S1444"-Make this "public static bulletL" field final( +C +java:S1444"-Make this "public static bulletR" field final( +C +java:S1444"-Make this "public static bulletU" field final( +C +java:S1444"-Make this "public static bulletD" field final( +I +java:S1444".Make this "public static explodes" field final( \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/e/b/ebd48d685c9a0a6dded8bb1c6d2c75c717c9c10d b/.idea/sonarlint/issuestore/e/b/ebd48d685c9a0a6dded8bb1c6d2c75c717c9c10d new file mode 100644 index 0000000..ee1fec6 --- /dev/null +++ b/.idea/sonarlint/issuestore/e/b/ebd48d685c9a0a6dded8bb1c6d2c75c717c9c10d @@ -0,0 +1,6 @@ + +K +java:S2209"5Change this instance-reference to a static reference.( +P +java:S2209"5Change this instance-reference to a static reference.( +t java:S120"ZRename this package name to match the regular expression '^[a-z_]+(\.[a-z_][a-z0-9_]*)*$'.( \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/f/0/f05c3638610e0ce274846e174c61431121775426 b/.idea/sonarlint/issuestore/f/0/f05c3638610e0ce274846e174c61431121775426 new file mode 100644 index 0000000..3b5b97b --- /dev/null +++ b/.idea/sonarlint/issuestore/f/0/f05c3638610e0ce274846e174c61431121775426 @@ -0,0 +1,5 @@ + +I +java:S1602",Remove useless curly braces around statement(80 +D +java:S2189""Add an end condition to this loop.(8ܹ0 \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/f/a/fa22466dc106d781e88480a5609428c6ed1e96c2 b/.idea/sonarlint/issuestore/f/a/fa22466dc106d781e88480a5609428c6ed1e96c2 new file mode 100644 index 0000000..e69de29 diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb new file mode 100644 index 0000000..bb099aa --- /dev/null +++ b/.idea/sonarlint/issuestore/index.pb @@ -0,0 +1,47 @@ + +> +study-tank.iml,6\9\69fcf7cf0cb84aa5f9c25dd41d8b89bcf868840a +] +-src/main/java/com/study/tank/PropertyMgr.java,f\a\fa22466dc106d781e88480a5609428c6ed1e96c2 +] +-src/main/java/com/study/tank/ImageManger.java,e\3\e33fa438c138d070344c0d8500f75aa75f823e55 +7 +pom.xml,4\4\442292b8a7efeabbe4cc176709b833b1792140ec +Y +)src/main/java/com/study/tank/Explode.java,a\7\a7a9714ccccb1e9cd6c18c07b50adb6fb63efde1 +e +5src/main/java/com/study/tank/factory/RectExplode.java,6\9\69e5f1fcaeb728725015172c220b41d4f2f3235c +e +5src/main/java/com/study/tank/factory/GameFactory.java,4\0\40f02948eb790c7986e5ecd2216cd56c8d1316c0 +g +7src/main/java/com/study/tank/strategy/FireStrategy.java,e\2\e2f699d7ece4648d65d8f55bbb53b4c1a97a0134 +e +5src/main/java/com/study/tank/factory/BaseExplode.java,7\3\739d9cb13e6b2724f1a0fbbf0a0a279d33a10ff3 +d +4src/main/java/com/study/tank/factory/BaseBullet.java,2\9\2995ce511c59d5daf350eb58870c6c2ad9774f9c +e +5src/main/java/com/study/tank/factory/RoundBullet.java,4\a\4a5d2311ad0ce6ee7cbe87839280d9b76f3a4b04 +X +(src/main/java/com/study/tank/Bullet.java,9\e\9e5a3f4cb2d4a5a75750157065729f2eb8cc0a07 +b +2src/main/java/com/study/tank/factory/BaseTank.java,9\d\9d993a8181111dcdfd4f4d45ff6e01eca290e383 +a +1src/main/java/com/study/tank/factory/WarTank.java,7\0\70f82ce88ac6b54afd6eed03fe6951084561b5c5 +e +5src/main/java/com/study/tank/factory/RectFactory.java,4\6\469cb43b51ba7e207f3767d69d0e3deded4e3c93 +V +&src/main/java/com/study/tank/Tank.java,0\8\081d67b31c95c91f6926f605dfc94fdd2bada262 +Z +*src/main/java/com/study/tank/TestMain.java,f\0\f05c3638610e0ce274846e174c61431121775426 +h +8src/main/java/com/study/tank/factory/DefaultFactory.java,8\a\8a8f68332c66aa57898f0442651ad801e856c9d1 +s +Csrc/main/java/com/study/tank/strategy/Imp/GoodTankFireStrategy.java,1\6\1652b301de6e1dadaab20f1f8c9dcf053f3cd3a7 +r +Bsrc/main/java/com/study/tank/strategy/Imp/DefaultFireStrategy.java,e\b\ebd48d685c9a0a6dded8bb1c6d2c75c717c9c10d +W +'src/main/java/com/study/tank/Audio.java,5\b\5bd8e55a95e8e3ef2459b7d56ee9a74443b8f788 +[ ++src/test/java/com/study/tank/ImageTest.java,9\7\97cf6348e49d166ce567c6eb53c9d085ee3b786c +[ ++src/main/java/com/study/tank/TankFrame.java,c\d\cd8bb0d273a44e56af2c725281536ed379107cc0 \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..133abe9 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + org.study.tank + study-tank + 1.0-SNAPSHOT + + + junit + junit + 4.12 + test + + + + org.springframework + spring-context + 5.3.23 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + \ No newline at end of file diff --git a/src/.DS_Store b/src/.DS_Store new file mode 100644 index 0000000..7b0d367 Binary files /dev/null and b/src/.DS_Store differ diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000..53fb051 Binary files /dev/null and b/src/main/.DS_Store differ diff --git a/src/main/java/com/study/tank/Audio.java b/src/main/java/com/study/tank/Audio.java new file mode 100644 index 0000000..c97a5eb --- /dev/null +++ b/src/main/java/com/study/tank/Audio.java @@ -0,0 +1,99 @@ + +package com.study.tank; + +import java.io.IOException; +import java.net.URL; + +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.FloatControl; +import javax.sound.sampled.SourceDataLine; + +public class Audio { + byte[] b = new byte[1024 * 1024 * 15]; + public void loop() { + try { + + while (true) { + int len = 0; + sourceDataLine.open(audioFormat, 1024 * 1024 * 15); + sourceDataLine.start(); + //System.out.println(audioInputStream.markSupported()); + audioInputStream.mark(12358946); + while ((len = audioInputStream.read(b)) > 0) { + sourceDataLine.write(b, 0, len); + } + audioInputStream.reset(); + + sourceDataLine.drain(); + sourceDataLine.close(); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + private AudioFormat audioFormat = null; + private SourceDataLine sourceDataLine = null; + private DataLine.Info dataLine_info = null; + + private AudioInputStream audioInputStream = null; + + public Audio(String fileName) { + try { + URL url = Audio.class.getClassLoader().getResource(fileName); + audioInputStream = AudioSystem.getAudioInputStream(url); + audioFormat = audioInputStream.getFormat(); + dataLine_info = new DataLine.Info(SourceDataLine.class, audioFormat); + sourceDataLine = (SourceDataLine) AudioSystem.getLine(dataLine_info); + //FloatControl volctrl=(FloatControl)sourceDataLine.getControl(FloatControl.Type.MASTER_GAIN); + //volctrl.setValue(-40);// + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void play() { + try { + byte[] b = new byte[1024*5]; + int len = 0; + sourceDataLine.open(audioFormat, 1024*5); + sourceDataLine.start(); + //System.out.println(audioInputStream.markSupported()); + audioInputStream.mark(12358946); + while ((len = audioInputStream.read(b)) > 0) { + sourceDataLine.write(b, 0, len); + } + // audioInputStream.reset(); + + sourceDataLine.drain(); + sourceDataLine.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } + + + + public void close() { + try { + audioInputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + +// public static void main(String[] args) { +// //URL url = Audio.class.getClassLoader().getResource("audio/explode.wav"); +// System.out.println("测试"); +// Audio a = new Audio("audio/explode.wav"); +//// //Audio a = new Audio("audio/explode.wav"); +// a.loop(); +// } + +} diff --git a/src/main/java/com/study/tank/Bullet.java b/src/main/java/com/study/tank/Bullet.java new file mode 100644 index 0000000..b3d8d67 --- /dev/null +++ b/src/main/java/com/study/tank/Bullet.java @@ -0,0 +1,104 @@ +package com.study.tank; + +import com.study.tank.factory.BaseBullet; +import com.study.tank.factory.BaseTank; + +import java.awt.*; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午11:16 + */ +public class Bullet extends BaseBullet { + public static final int bWidth = ImageManger.bulletL.getWidth(); + public static final int bHeight = ImageManger.bulletL.getHeight(); + private int x, y; + private Dir dir = Dir.DOWN; + private final int speed = 10; + private boolean living = true; + TankFrame tf = null; + private Group group = Group.BAD; + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public Bullet(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + this.x = x; + this.y = y; + this.dir = dir; + this.tf = tankFrame; + this.group = group; + tankFrame.bullets.add(this); + new Thread(() -> { + new Audio("audio/tank_fire.wav"); + }).start(); + } + + + public void paint(Graphics g) { + if (!living) tf.bullets.remove(this); + switch (dir) { + case DOWN: + g.drawImage(ImageManger.bulletD, x, y, null); + break; + case UP: + g.drawImage(ImageManger.bulletU, x, y, null); + break; + case RIGHT: + g.drawImage(ImageManger.bulletR, x, y, null); + break; + case LEFT: + g.drawImage(ImageManger.bulletL, x, y, null); + break; + } + move(); + } + + /** + * 移动 + */ + public void move() { + switch (dir) { + case LEFT: + x -= speed; + break; + case RIGHT: + x += speed; + break; + case UP: + y -= speed; + break; + case DOWN: + y += speed; + break; + } + if (x < 0 || y < 0 || x > TankFrame.GAME_WIDTH || y > TankFrame.GAME_HEIGHT) { + living = false; + } + } + + /** + * 碰撞 + */ + public void collideWithTank(BaseTank tank) { + if (this.group == tank.getGroup()) return; + Rectangle rect1 = new Rectangle(this.x, this.y, bWidth, bHeight); + Rectangle rect2 = new Rectangle(tank.getX(), tank.getY(), Tank.tankWidth, Tank.tankHeight); + //碰撞矩形 + if (rect1.intersects(rect2)) { + tank.die(); + this.die(); + tf.explodes.add(tf.gf.createExplode(this.x + bWidth / 2 - Explode.bWidth / 2, this.y + bWidth - Explode.bHeight / 2, tf)); + } + } + + public void die() { + this.living = false; + } +} diff --git a/src/main/java/com/study/tank/Dir.java b/src/main/java/com/study/tank/Dir.java new file mode 100644 index 0000000..ff4f199 --- /dev/null +++ b/src/main/java/com/study/tank/Dir.java @@ -0,0 +1,10 @@ +package com.study.tank; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午10:09 + */ +public enum Dir { + LEFT,RIGHT,UP,DOWN +} diff --git a/src/main/java/com/study/tank/Explode.java b/src/main/java/com/study/tank/Explode.java new file mode 100644 index 0000000..8b0f9fd --- /dev/null +++ b/src/main/java/com/study/tank/Explode.java @@ -0,0 +1,47 @@ +package com.study.tank; + +import com.study.tank.factory.BaseExplode; + +import java.awt.*; + +/** + * @Description: 爆炸 + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午11:16 + */ +public class Explode extends BaseExplode { + public static final int bWidth = ImageManger.explodes[0].getWidth(); + public static final int bHeight = ImageManger.explodes[0].getHeight(); + private int x, y; + TankFrame tf = null; + private int step = 0; + + + public Explode(int x, int y, TankFrame tankFrame) { + this.x = x; + this.y = y; + this.tf = tankFrame; + + new Thread(new Runnable() { + public void run() { + new Audio("audio/explode.wav").play(); + } + }).start(); + } + +// public void paint(Graphics g) { +// g.drawImage(ImageManger.explodes[step++], x, y, null); +// if (step >= ImageManger.explodes.length) { +// tf.explodes.remove(this); +// } +// } + + + @Override + public void paint(Graphics g) { + g.drawImage(ImageManger.explodes[step++], x, y, null); + if (step >= ImageManger.explodes.length) { + tf.explodes.remove(this); + } + } +} diff --git a/src/main/java/com/study/tank/Group.java b/src/main/java/com/study/tank/Group.java new file mode 100644 index 0000000..8362a84 --- /dev/null +++ b/src/main/java/com/study/tank/Group.java @@ -0,0 +1,10 @@ +package com.study.tank; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/下午1:49 + */ +public enum Group { + GOOD,BAD +} diff --git a/src/main/java/com/study/tank/ImageManger.java b/src/main/java/com/study/tank/ImageManger.java new file mode 100644 index 0000000..83b8cf1 --- /dev/null +++ b/src/main/java/com/study/tank/ImageManger.java @@ -0,0 +1,46 @@ +package com.study.tank; + +import com.study.tank.util.ImageUtil; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/下午12:37 + */ +public class ImageManger { + public static BufferedImage goodTankL, goodTankR, goodTankU, goodTankD; + public static BufferedImage badTankL, badTankR, badTankU, badTankD; + public static BufferedImage bulletL, bulletR, bulletU, bulletD; + public static BufferedImage[] explodes = new BufferedImage[16]; + + static { + try { + goodTankU = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/GoodTank1.png")); + goodTankD = ImageUtil.rotateImage(goodTankU, 180); + goodTankL = ImageUtil.rotateImage(goodTankU, -90); + goodTankR = ImageUtil.rotateImage(goodTankU, 90); + + badTankU = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/BadTank1.png")); + badTankD = ImageUtil.rotateImage(badTankU, 180); + badTankL = ImageUtil.rotateImage(badTankU, -90); + badTankR = ImageUtil.rotateImage(badTankU, 90); + + bulletL = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/bulletL.gif")); + bulletR = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/bulletR.gif")); + bulletU = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/bulletU.gif")); + bulletD = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/bulletD.gif")); + + for (int i = 0; i < 16; i++) { + explodes[i] = ImageIO.read(ImageManger.class.getClassLoader().getResourceAsStream("images/e" + (i + 1) + ".gif")); + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/main/java/com/study/tank/PropertyMgr.java b/src/main/java/com/study/tank/PropertyMgr.java new file mode 100644 index 0000000..f7f17f5 --- /dev/null +++ b/src/main/java/com/study/tank/PropertyMgr.java @@ -0,0 +1,33 @@ +package com.study.tank; + +import java.util.Properties; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/23/下午8:50 + */ +public class PropertyMgr { + static Properties properties = new Properties(); + + private PropertyMgr(){ + + } + + static { + try { + properties.load(PropertyMgr.class.getClassLoader().getResourceAsStream("config")); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Object get(String key) { + if (properties == null) return null; + return properties.get(key); + } + +// public static void main(String[] args) { +// System.out.println(PropertyMgr.get("initTankCount")); +// } +} diff --git a/src/main/java/com/study/tank/Tank.java b/src/main/java/com/study/tank/Tank.java new file mode 100644 index 0000000..d6e1bb5 --- /dev/null +++ b/src/main/java/com/study/tank/Tank.java @@ -0,0 +1,229 @@ +package com.study.tank; + +import com.study.tank.factory.BaseTank; +import com.study.tank.strategy.FireStrategy; +import com.study.tank.strategy.Imp.DefaultFireStrategy; +import com.study.tank.strategy.Imp.GoodTankFireStrategy; + +import java.awt.*; +import java.util.Random; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午10:08 + */ +public class Tank extends BaseTank { + public static final int tankWidth = ImageManger.goodTankU.getWidth(); + public static final int tankHeight = ImageManger.goodTankU.getHeight(); + private boolean moving = true; + // private int x, y; + private boolean living = true; + public Dir dir = Dir.DOWN; + private final int speed = 4; + public TankFrame tankFrame = null; + private Random random = new Random(); + //Group group = Group.BAD; + +// FireStrategy fs; + +// public Group getGroup() { +// return group; +// } +// +// public void setGroup(Group group) { +// this.group = group; +// } + + public Tank(int x, int y, Dir dir, Group group, TankFrame tankFrame) { +// this.x = x; +// this.y = y; + super(x, y, group); + this.dir = dir; + //this.group = group; + this.tankFrame = tankFrame; +// try { +// if (this.group == Group.GOOD) { +// String goodName = (String) PropertyMgr.get("goodFs"); +// //fs = (GoodTankFireStrategy) Class.forName(goodName).newInstance(); +// fs = (FireStrategy) Class.forName(goodName).getDeclaredConstructor().newInstance(); +// } else { +// fs = new DefaultFireStrategy(); +// } +// } catch (Exception e) { +// +// } + } + +// public Tank(int x, int y, Dir dir, Group group, boolean moving, TankFrame tankFrame) { +// this.x = x; +// this.y = y; +// this.dir = dir; +// this.group = group; +// this.tankFrame = tankFrame; +// this.moving = false; +// } + +// public int getX() { +// return x; +// } +// +// public int getY() { +// return y; +// } + + public Dir getDir() { + return dir; + } + + public int getSpeed() { + return speed; + } + +// public void setX(int x) { +// this.x = x; +// } +// +// public void setY(int y) { +// this.y = y; +// } + + public boolean isMoving() { + return moving; + } + + public void setMoving(boolean moving) { + this.moving = moving; + } + + public void setDir(Dir dir) { + this.dir = dir; + } + +// public void paint(Graphics g) { +// System.out.println("tank paint"); +// if (!living) { +// tankFrame.tanks.remove(this); +// moving = false; +// return; +// } +// switch (this.dir) { +// case DOWN: +// g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankD : ImageManger.badTankD, this.x, this.y, null); +// break; +// case UP: +// g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankU : ImageManger.badTankU, this.x, this.y, null); +// break; +// case RIGHT: +// g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankR : ImageManger.badTankR, this.x, this.y, null); +// break; +// case LEFT: +// g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankL : ImageManger.badTankL, this.x, this.y, null); +// break; +// } +// move(); +// } + + + @Override + public void paint(Graphics g) { + System.out.println("tank paint"); + if (!living) { + tankFrame.tanks.remove(this); + moving = false; + return; + } + switch (this.dir) { + case DOWN: + g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankD : ImageManger.badTankD, this.x, this.y, null); + break; + case UP: + g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankU : ImageManger.badTankU, this.x, this.y, null); + break; + case RIGHT: + g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankR : ImageManger.badTankR, this.x, this.y, null); + break; + case LEFT: + g.drawImage(this.group == Group.GOOD ? ImageManger.goodTankL : ImageManger.badTankL, this.x, this.y, null); + break; + } + move(); + } + + public void move() { + if (!living) return; + if (!this.moving) return; + switch (dir) { + case LEFT: + x -= speed; + break; + case RIGHT: + x += speed; + break; + case UP: + y -= speed; + break; + case DOWN: + y += speed; + break; + } + if (group == Group.BAD && random.nextInt(100) > 95) + this.fire(); + + if (this.group == Group.BAD && random.nextInt(100) > 95) + this.randomDir(); + + boundsCheck(); + if (group == Group.GOOD) { + new Thread(() -> { + new Audio("audio/tank_move.wav").play(); + }).start(); + } + } + + private void boundsCheck() { + if (this.x < 0) x = TankFrame.GAME_WIDTH - Tank.tankWidth; + if (this.y < 28) y = TankFrame.GAME_HEIGHT - Tank.tankHeight; + if (this.x > TankFrame.GAME_WIDTH - tankWidth) x = 0; + if (this.y > TankFrame.GAME_HEIGHT - tankHeight) y = 28; + } + + //0.4几率的随机方向 + private void randomDir() { + if (random.nextInt(100) > 60) + this.dir = Dir.values()[random.nextInt(4)]; + } + + /** + * 开火 + */ + public void fire() { + //fs.fire(this); + int bx = this.getX() + Tank.tankWidth / 2 - ImageManger.bulletD.getWidth() / 2; + int by = this.getY() + Tank.tankHeight / 2 - ImageManger.bulletD.getHeight() / 2; + switch (this.dir) { + case DOWN: + new Bullet(bx, by + 6, this.dir, this.getGroup(), this.tankFrame); + new Bullet(bx, by - 6, this.dir, this.getGroup(), this.tankFrame); + break; + case UP: + new Bullet(bx + 1, by + 6, this.dir, this.getGroup(), this.tankFrame); + new Bullet(bx + 1, by - 6, this.dir, this.getGroup(), this.tankFrame); + break; + case LEFT: + new Bullet(bx + 6, by, this.dir, this.getGroup(), this.tankFrame); + new Bullet(bx - 6, by, this.dir, this.getGroup(), this.tankFrame); + break; + case RIGHT: + new Bullet(bx + 6, by + 1, this.dir, this.getGroup(), this.tankFrame); + new Bullet(bx - 6, by + 1, this.dir, this.getGroup(), this.tankFrame); + break; + + } + } + + @Override + public void die() { + this.living = false; + } +} diff --git a/src/main/java/com/study/tank/TankFrame.java b/src/main/java/com/study/tank/TankFrame.java new file mode 100644 index 0000000..79e2317 --- /dev/null +++ b/src/main/java/com/study/tank/TankFrame.java @@ -0,0 +1,151 @@ +package com.study.tank; + +import com.study.tank.factory.*; + +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; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午9:14 + */ +public class TankFrame extends Frame { + public static final int GAME_WIDTH = Integer.parseInt((String) PropertyMgr.get("gameWidth")); + public static final int GAME_HEIGHT = Integer.parseInt((String) PropertyMgr.get("gameHeight")); + public ArrayList tanks = new ArrayList(); + public Tank myTank = new Tank(150, 150, Dir.DOWN, Group.GOOD, this); + public ArrayList bullets = new ArrayList(); + public ArrayList explodes = new ArrayList(); + public GameFactory gf = new DefaultFactory(); + + public TankFrame() { + //设置窗口大小 + this.setSize(GAME_WIDTH, GAME_HEIGHT); + this.setResizable(false);//不可改变窗口大小 + this.setTitle("Tank War");//设置标题 + this.setVisible(true);//设置窗口可见 + this.addKeyListener(new MyKeyListener()); + //窗口关闭系统停止运行 + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + } + + Image offScreenImage = null; + + @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); + } + + @Override + public void paint(Graphics g) { + Color c = g.getColor(); + g.setColor(Color.BLUE); + g.drawString("子弹的数量:" + bullets.size(), 5, 40); + g.drawString("敌人的数量:" + tanks.size(), 5, 60); + g.setColor(c); + myTank.paint(g); + for (int i = 0; i < tanks.size(); i++) { + tanks.get(i).paint(g); + } + for (int i = 0; i < bullets.size(); i++) { + bullets.get(i).paint(g); + } + for (int i = 0; i < bullets.size(); i++) { + for (int j = 0; j < tanks.size(); j++) { + bullets.get(i).collideWithTank(tanks.get(j)); + } + } + for (int i = 0; i < explodes.size(); i++) { + explodes.get(i).paint(g); + } + } + + /** + * 按键监听类 + */ + class MyKeyListener extends KeyAdapter { + boolean bL = false; + boolean bR = false; + boolean bU = false; + boolean bD = false; + + @Override + public void keyPressed(KeyEvent e) { + int key = e.getKeyCode(); + switch (key) { + case KeyEvent.VK_A: + bL = true; + break; + case KeyEvent.VK_D: + bR = true; + break; + case KeyEvent.VK_W: + bU = true; + break; + case KeyEvent.VK_S: + bD = true; + break; + } + setDirMethod(); + } + + @Override + public void keyReleased(KeyEvent e) { + super.keyReleased(e); + int key = e.getKeyCode(); + System.out.println("弹起:" + key); + switch (key) { + case KeyEvent.VK_A: + bL = false; + break; + case KeyEvent.VK_D: + bR = false; + break; + case KeyEvent.VK_W: + bU = false; + break; + case KeyEvent.VK_S: + bD = false; + break; + case KeyEvent.VK_SPACE: + myTank.fire(); + break; + } + setDirMethod(); + } + + public void setDirMethod() { + if (!bD && !bU && !bR && !bL) { + myTank.setMoving(false); + } else { + myTank.setMoving(true); + } + if (bL) myTank.setDir(Dir.LEFT); + if (bR) myTank.setDir(Dir.RIGHT); + if (bU) myTank.setDir(Dir.UP); + if (bD) myTank.setDir(Dir.DOWN); + } + + } + +} diff --git a/src/main/java/com/study/tank/TestMain.java b/src/main/java/com/study/tank/TestMain.java new file mode 100644 index 0000000..8ecdaa3 --- /dev/null +++ b/src/main/java/com/study/tank/TestMain.java @@ -0,0 +1,28 @@ +package com.study.tank; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/21/下午8:05 + */ +public class TestMain { + + public static void main(String[] args) throws InterruptedException { + + TankFrame tf = new TankFrame(); + //初始化敌人坦克 + int initCountTank = Integer.parseInt((String) PropertyMgr.get("initTankCount")); + for (int i = 0; i < initCountTank; i++) { + tf.tanks.add(tf.gf.createTank(80 + i * 100, 50, Dir.DOWN, Group.BAD, tf)); + } + + new Thread(() -> { + new Audio("audio/war1.wav").loop(); + }).start(); + + while (true) { + Thread.sleep(100); + tf.repaint(); + } + } +} diff --git a/src/main/java/com/study/tank/factory/BaseBullet.java b/src/main/java/com/study/tank/factory/BaseBullet.java new file mode 100644 index 0000000..67e8646 --- /dev/null +++ b/src/main/java/com/study/tank/factory/BaseBullet.java @@ -0,0 +1,16 @@ +package com.study.tank.factory; + +import com.study.tank.Tank; + +import java.awt.*; + +/** + * @author xsj + * @date 2022/10/26 13:14 + */ +public abstract class BaseBullet { + + public abstract void paint(Graphics g); + + public abstract void collideWithTank(BaseTank tank); +} diff --git a/src/main/java/com/study/tank/factory/BaseExplode.java b/src/main/java/com/study/tank/factory/BaseExplode.java new file mode 100644 index 0000000..d3e58cd --- /dev/null +++ b/src/main/java/com/study/tank/factory/BaseExplode.java @@ -0,0 +1,13 @@ +package com.study.tank.factory; + +import com.study.tank.TankFrame; + +import java.awt.*; + +/** + * @author xsj + * @date 2022/10/26 13:16 + */ +public abstract class BaseExplode { + public abstract void paint(Graphics g); +} diff --git a/src/main/java/com/study/tank/factory/BaseTank.java b/src/main/java/com/study/tank/factory/BaseTank.java new file mode 100644 index 0000000..b9c16bc --- /dev/null +++ b/src/main/java/com/study/tank/factory/BaseTank.java @@ -0,0 +1,50 @@ +package com.study.tank.factory; + +import com.study.tank.Dir; +import com.study.tank.Group; +import com.study.tank.TankFrame; + +import java.awt.*; + +/** + * @author xsj + * @date 2022/10/26 13:13 + */ +public abstract class BaseTank { + public Group group = Group.BAD; + public int x, y; + + public abstract void paint(Graphics g); + + public abstract void die(); + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + 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 BaseTank(int x, int y, Group group) { + this.group = group; + this.x = x; + this.y = y; + } +} diff --git a/src/main/java/com/study/tank/factory/DefaultFactory.java b/src/main/java/com/study/tank/factory/DefaultFactory.java new file mode 100644 index 0000000..322a22f --- /dev/null +++ b/src/main/java/com/study/tank/factory/DefaultFactory.java @@ -0,0 +1,25 @@ +package com.study.tank.factory; + +import com.study.tank.*; + +/** + * @author xsj + * @date 2022/10/26 13:13 + */ +public class DefaultFactory extends GameFactory { + + @Override + public BaseTank createTank(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + return new Tank(x, y, dir, group, tankFrame); + } + + @Override + public BaseBullet createBullet(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + return new Bullet(x,y,dir,group,tankFrame); + } + + @Override + public BaseExplode createExplode(int x, int y, TankFrame tankFrame) { + return new Explode(x, y, tankFrame); + } +} diff --git a/src/main/java/com/study/tank/factory/GameFactory.java b/src/main/java/com/study/tank/factory/GameFactory.java new file mode 100644 index 0000000..1b0746e --- /dev/null +++ b/src/main/java/com/study/tank/factory/GameFactory.java @@ -0,0 +1,18 @@ +package com.study.tank.factory; + +import com.study.tank.Dir; +import com.study.tank.Group; +import com.study.tank.TankFrame; + +/** + * @author xsj + * @date 2022/10/26 13:13 + */ +public abstract class GameFactory { + + public abstract BaseTank createTank(int x, int y, Dir dir, Group group, TankFrame tankFrame); + + public abstract BaseBullet createBullet(int x, int y, Dir dir, Group group, TankFrame tankFrame); + + public abstract BaseExplode createExplode(int x, int y, TankFrame tankFrame); +} diff --git a/src/main/java/com/study/tank/factory/RectExplode.java b/src/main/java/com/study/tank/factory/RectExplode.java new file mode 100644 index 0000000..d054829 --- /dev/null +++ b/src/main/java/com/study/tank/factory/RectExplode.java @@ -0,0 +1,46 @@ +package com.study.tank.factory; + +import com.study.tank.Audio; +import com.study.tank.ImageManger; +import com.study.tank.TankFrame; + +import java.awt.*; + +/** + * @author xsj + * @date 2022/10/26 13:37 + */ +public class RectExplode extends BaseExplode { + public static final int bWidth = ImageManger.explodes[0].getWidth(); + public static final int bHeight = ImageManger.explodes[0].getHeight(); + private int x, y; + TankFrame tf = null; + private int step = 0; + + + public RectExplode(int x, int y, TankFrame tankFrame) { + this.x = x; + this.y = y; + this.tf = tankFrame; + + new Thread(new Runnable() { + public void run() { + new Audio("audio/explode.wav").play(); + } + }).start(); + } + + @Override + public void paint(Graphics g) { +// g.drawImage(ImageManger.explodes[step++], x, y, null); + Color c = g.getColor(); + g.setColor(Color.red); + g.fillRect(x, y, 10 * step, 10 * step); +// if (step >= ImageManger.explodes.length) { +// tf.explodes.remove(this); +// } + step++; + if (step > 5) tf.explodes.remove(this); + g.setColor(c); + } +} diff --git a/src/main/java/com/study/tank/factory/RectFactory.java b/src/main/java/com/study/tank/factory/RectFactory.java new file mode 100644 index 0000000..e951037 --- /dev/null +++ b/src/main/java/com/study/tank/factory/RectFactory.java @@ -0,0 +1,25 @@ +package com.study.tank.factory; + +import com.study.tank.*; + +/** + * @author xsj + * @date 2022/10/26 13:36 + */ +public class RectFactory extends GameFactory { + + @Override + public BaseTank createTank(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + return new WarTank(x, y, dir, group, tankFrame); + } + + @Override + public BaseBullet createBullet(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + return new RoundBullet(x, y, dir, group, tankFrame); + } + + @Override + public BaseExplode createExplode(int x, int y, TankFrame tankFrame) { + return new RectExplode(x, y, tankFrame); + } +} diff --git a/src/main/java/com/study/tank/factory/RoundBullet.java b/src/main/java/com/study/tank/factory/RoundBullet.java new file mode 100644 index 0000000..7f137bd --- /dev/null +++ b/src/main/java/com/study/tank/factory/RoundBullet.java @@ -0,0 +1,125 @@ +package com.study.tank.factory; + +import com.study.tank.*; + +import java.awt.*; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午11:16 + */ +public class RoundBullet extends BaseBullet { + public static final int bWidth = ImageManger.bulletL.getWidth(); + public static final int bHeight = ImageManger.bulletL.getHeight(); + private int x, y; + private Dir dir = Dir.DOWN; + private final int speed = 10; + private boolean living = true; + TankFrame tf = null; + private Group group = Group.BAD; + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public RoundBullet(int x, int y, Dir dir, Group group, TankFrame tankFrame) { + this.x = x; + this.y = y; + this.dir = dir; + this.tf = tankFrame; + this.group = group; + tankFrame.bullets.add(this); + new Thread(() -> { + new Audio("audio/tank_fire.wav"); + }).start(); + } + + @Override + public void paint(Graphics g) { + if (!living) tf.bullets.remove(this); + Color c = g.getColor(); + g.setColor(Color.RED); + g.fillOval(x, y, 20, 20); + g.setColor(c); + move(); + } + +// public void paint(Graphics g) { +// if (!living) tf.bullets.remove(this); +// switch (dir) { +// case DOWN: +// g.drawImage(ImageManger.bulletD, x, y, null); +// break; +// case UP: +// g.drawImage(ImageManger.bulletU, x, y, null); +// break; +// case RIGHT: +// g.drawImage(ImageManger.bulletR, x, y, null); +// break; +// case LEFT: +// g.drawImage(ImageManger.bulletL, x, y, null); +// break; +// } +// move(); +// } + + /** + * 移动 + */ + public void move() { + switch (dir) { + case LEFT: + x -= speed; + break; + case RIGHT: + x += speed; + break; + case UP: + y -= speed; + break; + case DOWN: + y += speed; + break; + } + if (x < 0 || y < 0 || x > TankFrame.GAME_WIDTH || y > TankFrame.GAME_HEIGHT) { + living = false; + } + } + + /** + * 碰撞 + */ +// public void collideWithTank(Tank tank) { +// if (this.group == tank.getGroup()) return; +// Rectangle rect1 = new Rectangle(this.x, this.y, bWidth, bHeight); +// Rectangle rect2 = new Rectangle(tank.getX(), tank.getY(), Tank.tankWidth, Tank.tankHeight); +// //碰撞矩形 +// if (rect1.intersects(rect2)) { +// tank.die(); +// this.die(); +// tf.explodes.add(tf.gf.createExplode(this.x + bWidth / 2 - Explode.bWidth / 2, this.y + bWidth - Explode.bHeight / 2, tf)); +// } +// } + @Override + public void collideWithTank(BaseTank tank) { + if (this.group == tank.getGroup()) return; + Rectangle rect1 = new Rectangle(this.x, this.y, bWidth, bHeight); + Rectangle rect2 = new Rectangle(tank.getX(), tank.getY(), Tank.tankWidth, Tank.tankHeight); + //碰撞矩形 + if (rect1.intersects(rect2)) { + tank.die(); + this.die(); + tf.explodes.add(tf.gf.createExplode(this.x + bWidth / 2 - Explode.bWidth / 2, this.y + bWidth - Explode.bHeight / 2, tf)); + } + } + + public void die() { + this.living = false; + } + +} diff --git a/src/main/java/com/study/tank/factory/WarTank.java b/src/main/java/com/study/tank/factory/WarTank.java new file mode 100644 index 0000000..dc1f658 --- /dev/null +++ b/src/main/java/com/study/tank/factory/WarTank.java @@ -0,0 +1,170 @@ +package com.study.tank.factory; + +import com.study.tank.*; +import com.study.tank.strategy.FireStrategy; +import com.study.tank.strategy.Imp.DefaultFireStrategy; + +import java.awt.*; +import java.util.Random; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/22/上午10:08 + */ +public class WarTank extends BaseTank { + public static final int tankWidth = ImageManger.goodTankU.getWidth(); + public static final int tankHeight = ImageManger.goodTankU.getHeight(); + private boolean moving = true; + private int x, y; + private boolean living = true; + public Dir dir = Dir.DOWN; + private final int speed = 4; + public TankFrame tankFrame = null; + private Random random = new Random(); + Group group = Group.BAD; + + FireStrategy fs; + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public WarTank(int x, int y, Dir dir, Group group, TankFrame tankFrame) { +// this.x = x; +// this.y = y; + super(x, y, group); + this.dir = dir; +// this.group = group; + this.tankFrame = tankFrame; + try { + if (this.group == Group.GOOD) { + String goodName = (String) PropertyMgr.get("goodFs"); + //fs = (GoodTankFireStrategy) Class.forName(goodName).newInstance(); + fs = (FireStrategy) Class.forName(goodName).getDeclaredConstructor().newInstance(); + } else { + fs = new DefaultFireStrategy(); + } + } catch (Exception e) { + + } + } + +// public Tank(int x, int y, Dir dir, Group group, boolean moving, TankFrame tankFrame) { +// this.x = x; +// this.y = y; +// this.dir = dir; +// this.group = group; +// this.tankFrame = tankFrame; +// this.moving = false; +// } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public Dir getDir() { + return dir; + } + + public int getSpeed() { + return speed; + } + + public void setX(int x) { + this.x = x; + } + + public void setY(int y) { + this.y = y; + } + + public boolean isMoving() { + return moving; + } + + public void setMoving(boolean moving) { + this.moving = moving; + } + + public void setDir(Dir dir) { + this.dir = dir; + } + + @Override + public void paint(Graphics g) { + System.out.println("war paint"); + if (!living) { + tankFrame.tanks.remove(this); + moving = false; + return; + } + Color c = g.getColor(); + g.setColor(group == Group.GOOD ? Color.BLUE : Color.YELLOW); + g.fillRect(x, y, 40, 40); + g.setColor(c); + move(); + } + + public void move() { + if (!living) return; + if (!this.moving) return; + switch (dir) { + case LEFT: + x -= speed; + break; + case RIGHT: + x += speed; + break; + case UP: + y -= speed; + break; + case DOWN: + y += speed; + break; + } + if (group == Group.BAD && random.nextInt(100) > 95) + this.fire(); + + if (this.group == Group.BAD && random.nextInt(100) > 95) + this.randomDir(); + + boundsCheck(); + } + + private void boundsCheck() { + if (this.x < 0) x = TankFrame.GAME_WIDTH - WarTank.tankWidth; + if (this.y < 28) y = TankFrame.GAME_HEIGHT - WarTank.tankHeight; + if (this.x > TankFrame.GAME_WIDTH - tankWidth) x = 0; + if (this.y > TankFrame.GAME_HEIGHT - tankHeight) y = 28; + } + + //0.4几率的随机方向 + private void randomDir() { + if (random.nextInt(100) > 60) + this.dir = Dir.values()[random.nextInt(4)]; + } + + /** + * 开火 + */ + public void fire() { + //fs.fire(this); + int bx = this.getX() + this.tankWidth / 2 - ImageManger.bulletD.getWidth() / 2 + 2; + int by = this.getY() + this.tankHeight / 2 - ImageManger.bulletD.getHeight() / 2 + 2; + new Bullet(bx, by, this.dir, this.getGroup(), this.tankFrame); + } + + @Override + public void die() { + this.living = false; + } +} diff --git a/src/main/java/com/study/tank/strategy/FireStrategy.java b/src/main/java/com/study/tank/strategy/FireStrategy.java new file mode 100644 index 0000000..3ca01ff --- /dev/null +++ b/src/main/java/com/study/tank/strategy/FireStrategy.java @@ -0,0 +1,12 @@ +package com.study.tank.strategy; + +import com.study.tank.Tank; + +/** + * @author xsj + * @date 2022/10/25 10:30 + */ +public interface FireStrategy { + + void fire(Tank tank); +} diff --git a/src/main/java/com/study/tank/strategy/Imp/DefaultFireStrategy.java b/src/main/java/com/study/tank/strategy/Imp/DefaultFireStrategy.java new file mode 100644 index 0000000..b575f10 --- /dev/null +++ b/src/main/java/com/study/tank/strategy/Imp/DefaultFireStrategy.java @@ -0,0 +1,20 @@ +package com.study.tank.strategy.Imp; + +import com.study.tank.Bullet; +import com.study.tank.ImageManger; +import com.study.tank.Tank; +import com.study.tank.strategy.FireStrategy; + +/** + * @author xsj + * @date 2022/10/25 10:30 + */ +public class DefaultFireStrategy implements FireStrategy { + + @Override + public void fire(Tank tank) { + int bx = tank.getX() + tank.tankWidth / 2 - ImageManger.bulletD.getWidth() / 2 + 2; + int by = tank.getY() + tank.tankHeight / 2 - ImageManger.bulletD.getHeight() / 2 + 2; + new Bullet(bx, by, tank.dir, tank.getGroup(), tank.tankFrame); + } +} diff --git a/src/main/java/com/study/tank/strategy/Imp/GoodTankFireStrategy.java b/src/main/java/com/study/tank/strategy/Imp/GoodTankFireStrategy.java new file mode 100644 index 0000000..2759d13 --- /dev/null +++ b/src/main/java/com/study/tank/strategy/Imp/GoodTankFireStrategy.java @@ -0,0 +1,39 @@ +package com.study.tank.strategy.Imp; + +import com.study.tank.Bullet; +import com.study.tank.ImageManger; +import com.study.tank.Tank; +import com.study.tank.strategy.FireStrategy; + +/** + * @author xsj + * @date 2022/10/25 13:28 + */ +public class GoodTankFireStrategy implements FireStrategy { + + @Override + public void fire(Tank tank) { + int bx = tank.getX() + Tank.tankWidth / 2 - ImageManger.bulletD.getWidth() / 2; + int by = tank.getY() + Tank.tankHeight / 2 - ImageManger.bulletD.getHeight() / 2; + switch (tank.dir) { + case DOWN: + new Bullet(bx, by + 6, tank.dir, tank.getGroup(), tank.tankFrame); + new Bullet(bx, by - 6, tank.dir, tank.getGroup(), tank.tankFrame); + break; + case UP: + new Bullet(bx + 1, by + 6, tank.dir, tank.getGroup(), tank.tankFrame); + new Bullet(bx + 1, by - 6, tank.dir, tank.getGroup(), tank.tankFrame); + break; + case LEFT: + new Bullet(bx + 6, by, tank.dir, tank.getGroup(), tank.tankFrame); + new Bullet(bx - 6, by, tank.dir, tank.getGroup(), tank.tankFrame); + break; + case RIGHT: + new Bullet(bx + 6, by + 1, tank.dir, tank.getGroup(), tank.tankFrame); + new Bullet(bx - 6, by + 1, tank.dir, tank.getGroup(), tank.tankFrame); + break; + + } + + } +} diff --git a/src/main/java/com/study/tank/util/ImageUtil.java b/src/main/java/com/study/tank/util/ImageUtil.java new file mode 100644 index 0000000..7d18a2a --- /dev/null +++ b/src/main/java/com/study/tank/util/ImageUtil.java @@ -0,0 +1,28 @@ +package com.study.tank.util; + +import java.awt.*; +import java.awt.image.BufferedImage; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/23/下午7:08 + */ +public class ImageUtil { + public static BufferedImage rotateImage(final BufferedImage bufferedImage, + final int degree) { + int w = bufferedImage.getWidth(); + int h = bufferedImage.getHeight(); + int type = bufferedImage.getColorModel().getTransparency(); + BufferedImage img; + Graphics2D graphics2D; + (graphics2D = (img = new BufferedImage(w, h, type)) + .createGraphics()).setRenderingHint( + RenderingHints.KEY_INTERPOLATION, + RenderingHints.VALUE_INTERPOLATION_BILINEAR); + graphics2D.rotate(Math.toRadians(degree), w / 2, h / 2); + graphics2D.drawImage(bufferedImage, 0, 0, null); + graphics2D.dispose(); + return img; + } +} diff --git a/src/main/resources/audio/explode.wav b/src/main/resources/audio/explode.wav new file mode 100644 index 0000000..dc72ab1 Binary files /dev/null and b/src/main/resources/audio/explode.wav differ diff --git a/src/main/resources/audio/tank_fire.wav b/src/main/resources/audio/tank_fire.wav new file mode 100644 index 0000000..85279eb Binary files /dev/null and b/src/main/resources/audio/tank_fire.wav differ diff --git a/src/main/resources/audio/tank_move.wav b/src/main/resources/audio/tank_move.wav new file mode 100644 index 0000000..959b998 Binary files /dev/null and b/src/main/resources/audio/tank_move.wav differ diff --git a/src/main/resources/audio/war1.wav b/src/main/resources/audio/war1.wav new file mode 100644 index 0000000..099a31e Binary files /dev/null and b/src/main/resources/audio/war1.wav differ diff --git a/src/main/resources/config b/src/main/resources/config new file mode 100644 index 0000000..cac8425 --- /dev/null +++ b/src/main/resources/config @@ -0,0 +1,9 @@ +#tanks count at initialization +initTankCount=10 +tankSpeed=5 +bulletSpeed=10 +gameWidth=1080 +gameHeight=720 +#strategy +goodFs=com.study.tank.strategy.Imp.GoodTankFireStrategy +badFs=com.study.tank.strategy.Imp.DefaultFireStrategy \ No newline at end of file diff --git a/src/main/resources/images/0.gif b/src/main/resources/images/0.gif new file mode 100644 index 0000000..79c5218 Binary files /dev/null and b/src/main/resources/images/0.gif differ diff --git a/src/main/resources/images/1.gif b/src/main/resources/images/1.gif new file mode 100644 index 0000000..eface51 Binary files /dev/null and b/src/main/resources/images/1.gif differ diff --git a/src/main/resources/images/10.gif b/src/main/resources/images/10.gif new file mode 100644 index 0000000..ffd49b8 Binary files /dev/null and b/src/main/resources/images/10.gif differ diff --git a/src/main/resources/images/2.gif b/src/main/resources/images/2.gif new file mode 100644 index 0000000..b88b47e Binary files /dev/null and b/src/main/resources/images/2.gif differ diff --git a/src/main/resources/images/3.gif b/src/main/resources/images/3.gif new file mode 100644 index 0000000..88e81e8 Binary files /dev/null and b/src/main/resources/images/3.gif differ diff --git a/src/main/resources/images/4.gif b/src/main/resources/images/4.gif new file mode 100644 index 0000000..4cc91ab Binary files /dev/null and b/src/main/resources/images/4.gif differ diff --git a/src/main/resources/images/5.gif b/src/main/resources/images/5.gif new file mode 100644 index 0000000..c1cc5d7 Binary files /dev/null and b/src/main/resources/images/5.gif differ diff --git a/src/main/resources/images/6.gif b/src/main/resources/images/6.gif new file mode 100644 index 0000000..4f43fc7 Binary files /dev/null and b/src/main/resources/images/6.gif differ diff --git a/src/main/resources/images/7.gif b/src/main/resources/images/7.gif new file mode 100644 index 0000000..20358ba Binary files /dev/null and b/src/main/resources/images/7.gif differ diff --git a/src/main/resources/images/8.gif b/src/main/resources/images/8.gif new file mode 100644 index 0000000..ae410c9 Binary files /dev/null and b/src/main/resources/images/8.gif differ diff --git a/src/main/resources/images/9.gif b/src/main/resources/images/9.gif new file mode 100644 index 0000000..11efedd Binary files /dev/null and b/src/main/resources/images/9.gif differ diff --git a/src/main/resources/images/BadTank1.png b/src/main/resources/images/BadTank1.png new file mode 100644 index 0000000..d661b80 Binary files /dev/null and b/src/main/resources/images/BadTank1.png differ diff --git a/src/main/resources/images/BadTank2.png b/src/main/resources/images/BadTank2.png new file mode 100644 index 0000000..c2a2b01 Binary files /dev/null and b/src/main/resources/images/BadTank2.png differ diff --git a/src/main/resources/images/GoodTank1.png b/src/main/resources/images/GoodTank1.png new file mode 100644 index 0000000..8afb8b0 Binary files /dev/null and b/src/main/resources/images/GoodTank1.png differ diff --git a/src/main/resources/images/GoodTank2.png b/src/main/resources/images/GoodTank2.png new file mode 100644 index 0000000..a1b131a Binary files /dev/null and b/src/main/resources/images/GoodTank2.png differ diff --git a/src/main/resources/images/bulletD.gif b/src/main/resources/images/bulletD.gif new file mode 100644 index 0000000..be33e5f Binary files /dev/null and b/src/main/resources/images/bulletD.gif differ diff --git a/src/main/resources/images/bulletL.gif b/src/main/resources/images/bulletL.gif new file mode 100644 index 0000000..1ab986a Binary files /dev/null and b/src/main/resources/images/bulletL.gif differ diff --git a/src/main/resources/images/bulletR.gif b/src/main/resources/images/bulletR.gif new file mode 100644 index 0000000..514e982 Binary files /dev/null and b/src/main/resources/images/bulletR.gif differ diff --git a/src/main/resources/images/bulletU.gif b/src/main/resources/images/bulletU.gif new file mode 100644 index 0000000..274c570 Binary files /dev/null and b/src/main/resources/images/bulletU.gif differ diff --git a/src/main/resources/images/bulletU.png b/src/main/resources/images/bulletU.png new file mode 100644 index 0000000..f6f7203 Binary files /dev/null and b/src/main/resources/images/bulletU.png differ diff --git a/src/main/resources/images/e1.gif b/src/main/resources/images/e1.gif new file mode 100644 index 0000000..4ba0e92 Binary files /dev/null and b/src/main/resources/images/e1.gif differ diff --git a/src/main/resources/images/e10.gif b/src/main/resources/images/e10.gif new file mode 100644 index 0000000..5667574 Binary files /dev/null and b/src/main/resources/images/e10.gif differ diff --git a/src/main/resources/images/e11.gif b/src/main/resources/images/e11.gif new file mode 100644 index 0000000..7d6747c Binary files /dev/null and b/src/main/resources/images/e11.gif differ diff --git a/src/main/resources/images/e12.gif b/src/main/resources/images/e12.gif new file mode 100644 index 0000000..97f85df Binary files /dev/null and b/src/main/resources/images/e12.gif differ diff --git a/src/main/resources/images/e13.gif b/src/main/resources/images/e13.gif new file mode 100644 index 0000000..473cab1 Binary files /dev/null and b/src/main/resources/images/e13.gif differ diff --git a/src/main/resources/images/e14.gif b/src/main/resources/images/e14.gif new file mode 100644 index 0000000..676fa2a Binary files /dev/null and b/src/main/resources/images/e14.gif differ diff --git a/src/main/resources/images/e15.gif b/src/main/resources/images/e15.gif new file mode 100644 index 0000000..d3795f8 Binary files /dev/null and b/src/main/resources/images/e15.gif differ diff --git a/src/main/resources/images/e16.gif b/src/main/resources/images/e16.gif new file mode 100644 index 0000000..4a913c3 Binary files /dev/null and b/src/main/resources/images/e16.gif differ diff --git a/src/main/resources/images/e2.gif b/src/main/resources/images/e2.gif new file mode 100644 index 0000000..f22cbb8 Binary files /dev/null and b/src/main/resources/images/e2.gif differ diff --git a/src/main/resources/images/e3.gif b/src/main/resources/images/e3.gif new file mode 100644 index 0000000..58c1e2a Binary files /dev/null and b/src/main/resources/images/e3.gif differ diff --git a/src/main/resources/images/e4.gif b/src/main/resources/images/e4.gif new file mode 100644 index 0000000..981e9e2 Binary files /dev/null and b/src/main/resources/images/e4.gif differ diff --git a/src/main/resources/images/e5.gif b/src/main/resources/images/e5.gif new file mode 100644 index 0000000..fc93522 Binary files /dev/null and b/src/main/resources/images/e5.gif differ diff --git a/src/main/resources/images/e6.gif b/src/main/resources/images/e6.gif new file mode 100644 index 0000000..1bba69a Binary files /dev/null and b/src/main/resources/images/e6.gif differ diff --git a/src/main/resources/images/e7.gif b/src/main/resources/images/e7.gif new file mode 100644 index 0000000..9719061 Binary files /dev/null and b/src/main/resources/images/e7.gif differ diff --git a/src/main/resources/images/e8.gif b/src/main/resources/images/e8.gif new file mode 100644 index 0000000..710d7ea Binary files /dev/null and b/src/main/resources/images/e8.gif differ diff --git a/src/main/resources/images/e9.gif b/src/main/resources/images/e9.gif new file mode 100644 index 0000000..0535c88 Binary files /dev/null and b/src/main/resources/images/e9.gif differ diff --git a/src/main/resources/images/missileLD.gif b/src/main/resources/images/missileLD.gif new file mode 100644 index 0000000..4a1d311 Binary files /dev/null and b/src/main/resources/images/missileLD.gif differ diff --git a/src/main/resources/images/missileLU.gif b/src/main/resources/images/missileLU.gif new file mode 100644 index 0000000..e1fb913 Binary files /dev/null and b/src/main/resources/images/missileLU.gif differ diff --git a/src/main/resources/images/missileRD.gif b/src/main/resources/images/missileRD.gif new file mode 100644 index 0000000..d58cc9c Binary files /dev/null and b/src/main/resources/images/missileRD.gif differ diff --git a/src/main/resources/images/missileRU.gif b/src/main/resources/images/missileRU.gif new file mode 100644 index 0000000..1eed195 Binary files /dev/null and b/src/main/resources/images/missileRU.gif differ diff --git a/src/main/resources/images/square0.jpg b/src/main/resources/images/square0.jpg new file mode 100644 index 0000000..5b80bf0 Binary files /dev/null and b/src/main/resources/images/square0.jpg differ diff --git a/src/main/resources/images/square1.jpg b/src/main/resources/images/square1.jpg new file mode 100644 index 0000000..324341d Binary files /dev/null and b/src/main/resources/images/square1.jpg differ diff --git a/src/main/resources/images/square2.jpg b/src/main/resources/images/square2.jpg new file mode 100644 index 0000000..be66ad8 Binary files /dev/null and b/src/main/resources/images/square2.jpg differ diff --git a/src/main/resources/images/square3.jpg b/src/main/resources/images/square3.jpg new file mode 100644 index 0000000..109430b Binary files /dev/null and b/src/main/resources/images/square3.jpg differ diff --git a/src/main/resources/images/square4.jpg b/src/main/resources/images/square4.jpg new file mode 100644 index 0000000..ba00d68 Binary files /dev/null and b/src/main/resources/images/square4.jpg differ diff --git a/src/main/resources/images/square5.jpg b/src/main/resources/images/square5.jpg new file mode 100644 index 0000000..56198aa Binary files /dev/null and b/src/main/resources/images/square5.jpg differ diff --git a/src/main/resources/images/square6.jpg b/src/main/resources/images/square6.jpg new file mode 100644 index 0000000..2923b9a Binary files /dev/null and b/src/main/resources/images/square6.jpg differ diff --git a/src/main/resources/images/tank.png b/src/main/resources/images/tank.png new file mode 100644 index 0000000..54c82ba Binary files /dev/null and b/src/main/resources/images/tank.png differ diff --git a/src/main/resources/images/tank1U.jpg b/src/main/resources/images/tank1U.jpg new file mode 100644 index 0000000..faa0938 Binary files /dev/null and b/src/main/resources/images/tank1U.jpg differ diff --git a/src/main/resources/images/tankD.gif b/src/main/resources/images/tankD.gif new file mode 100644 index 0000000..4c29adf Binary files /dev/null and b/src/main/resources/images/tankD.gif differ diff --git a/src/main/resources/images/tankL.gif b/src/main/resources/images/tankL.gif new file mode 100644 index 0000000..af51e88 Binary files /dev/null and b/src/main/resources/images/tankL.gif differ diff --git a/src/main/resources/images/tankLD.gif b/src/main/resources/images/tankLD.gif new file mode 100644 index 0000000..2f6bca7 Binary files /dev/null and b/src/main/resources/images/tankLD.gif differ diff --git a/src/main/resources/images/tankLU.gif b/src/main/resources/images/tankLU.gif new file mode 100644 index 0000000..1e1a514 Binary files /dev/null and b/src/main/resources/images/tankLU.gif differ diff --git a/src/main/resources/images/tankR.gif b/src/main/resources/images/tankR.gif new file mode 100644 index 0000000..a83f583 Binary files /dev/null and b/src/main/resources/images/tankR.gif differ diff --git a/src/main/resources/images/tankRD.gif b/src/main/resources/images/tankRD.gif new file mode 100644 index 0000000..60e2e81 Binary files /dev/null and b/src/main/resources/images/tankRD.gif differ diff --git a/src/main/resources/images/tankRU.gif b/src/main/resources/images/tankRU.gif new file mode 100644 index 0000000..d66ef25 Binary files /dev/null and b/src/main/resources/images/tankRU.gif differ diff --git a/src/main/resources/images/tankU.gif b/src/main/resources/images/tankU.gif new file mode 100644 index 0000000..8825a23 Binary files /dev/null and b/src/main/resources/images/tankU.gif differ diff --git a/src/test/java/com/study/tank/ImageTest.java b/src/test/java/com/study/tank/ImageTest.java new file mode 100644 index 0000000..30db293 --- /dev/null +++ b/src/test/java/com/study/tank/ImageTest.java @@ -0,0 +1,16 @@ +package com.study.tank; + +import org.junit.Test; + +/** + * @Description: + * @Auther: xiaoshengjie + * @Date: 2022/10/21/下午8:08 + */ +public class ImageTest { + + @Test + public void test(){ + System.out.println("测试"); + } +} diff --git a/study-tank.iml b/study-tank.iml new file mode 100644 index 0000000..10643b4 --- /dev/null +++ b/study-tank.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file