From a3562d219d920e6262a8ccb55b3efccf12f348f3 Mon Sep 17 00:00:00 2001 From: jkonert Date: Tue, 26 Apr 2022 09:02:30 +0200 Subject: [PATCH 1/4] fixed Eclipse settings for JRE version (fixes the compile error) --- GameProject/.settings/org.eclipse.jdt.core.prefs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/GameProject/.settings/org.eclipse.jdt.core.prefs b/GameProject/.settings/org.eclipse.jdt.core.prefs index a3f49f6..e50443c 100644 --- a/GameProject/.settings/org.eclipse.jdt.core.prefs +++ b/GameProject/.settings/org.eclipse.jdt.core.prefs @@ -1,9 +1,9 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=12 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=12 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -12,4 +12,4 @@ org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=12 +org.eclipse.jdt.core.compiler.source=1.8 From f57728e382407b16e3f841345b9207c0e78fd5e0 Mon Sep 17 00:00:00 2001 From: jkonert Date: Tue, 26 Apr 2022 21:19:16 +0200 Subject: [PATCH 2/4] (code cleanup) removed obsolete imports and variables --- GameProject/src/collider/CircleCollider.java | 9 ++------- GameProject/src/collider/Collider.java | 2 -- GameProject/src/collider/RectCollider.java | 5 ----- GameProject/src/controller/EnemyController.java | 5 +++-- GameProject/src/controller/MineController.java | 1 - GameProject/src/gameobjects/AnimatedGameobject.java | 2 -- GameProject/src/gameobjects/EgoObject.java | 8 -------- GameProject/src/gameobjects/FallingStar.java | 4 +--- GameProject/src/gameobjects/RectObject.java | 2 -- GameProject/src/gameobjects/TextObject.java | 6 ------ GameProject/src/playground/Animation.java | 2 -- GameProject/src/playground/LevelHitTwice.java | 5 ----- GameProject/src/playground/SpaceInvadersLevel.java | 3 --- GameProject/src/playground/SpaceInvadersLevelTest.java | 8 ++++---- GameProject/src/rendering/RectArtist.java | 2 -- GameProject/src/rendering/TextArtist.java | 9 +++++++-- GameProject/src/ui/GameUI.java | 1 - 17 files changed, 17 insertions(+), 57 deletions(-) diff --git a/GameProject/src/collider/CircleCollider.java b/GameProject/src/collider/CircleCollider.java index c968a1b..56743c3 100644 --- a/GameProject/src/collider/CircleCollider.java +++ b/GameProject/src/collider/CircleCollider.java @@ -1,6 +1,5 @@ package collider; -import java.awt.Color; import gameobjects.*; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -17,7 +16,7 @@ public class CircleCollider extends Collider { double r; private static Logger logger = LogManager.getLogger(Collider.class); - + /** * Constructor which sets the radius to be respected for collisions. * @@ -48,7 +47,7 @@ public class CircleCollider extends Collider { public boolean checkCollisionCircCirc(Collider _c2) throws Exception { CircleCollider c2 = (CircleCollider) _c2; CircleCollider c1 = this; - logger.trace(c1.x + " " + c1.y + " " + c1.r + " " + c2.x + " " + c2.y+ " " + c2.r); + logger.trace(c1.x + " " + c1.y + " " + c1.r + " " + c2.x + " " + c2.y + " " + c2.r); int kathete1 = (int) (Math.abs(c2.gameobject.getX() - c1.gameobject.getX())); int kathete2 = (int) (Math.abs(c2.gameobject.getX() - c1.gameobject.getY())); int hypothenuse = (int) (c1.r + c2.r); @@ -81,8 +80,4 @@ public class CircleCollider extends Collider { throw new RuntimeException("Collider type not implemented!"); } - private Color color = Color.WHITE; - - - } diff --git a/GameProject/src/collider/Collider.java b/GameProject/src/collider/Collider.java index 0651db3..81793cd 100644 --- a/GameProject/src/collider/Collider.java +++ b/GameProject/src/collider/Collider.java @@ -1,7 +1,5 @@ package collider; -import java.awt.Graphics2D; -import java.util.LinkedList; import gameobjects.GameObject; import playground.Playground; import controller.ObjectController; diff --git a/GameProject/src/collider/RectCollider.java b/GameProject/src/collider/RectCollider.java index f25e62b..c781c8b 100644 --- a/GameProject/src/collider/RectCollider.java +++ b/GameProject/src/collider/RectCollider.java @@ -1,7 +1,5 @@ package collider; -import java.awt.Color; - import gameobjects.*; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -13,11 +11,8 @@ public class RectCollider extends Collider { //double x; //double y; - //double vx; - //double vy; double w, h; - private Color color = Color.WHITE; private static Logger logger = LogManager.getLogger(RectCollider.class); diff --git a/GameProject/src/controller/EnemyController.java b/GameProject/src/controller/EnemyController.java index 71e5c7e..9e6aa6c 100644 --- a/GameProject/src/controller/EnemyController.java +++ b/GameProject/src/controller/EnemyController.java @@ -1,6 +1,7 @@ package controller; +import playground.Playground; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; @@ -27,8 +28,8 @@ public class EnemyController extends ObjectController { if (gameObject.getY() >= this.getPlayground().getSizeY()) { this.getPlayground().deleteObject(gameObject.getId()); // add to points counter - Integer pts = (Integer) this.getPlayground().getGlobalFlag("points"); - this.getPlayground().setGlobalFlag("points", pts - 200); + Integer pts = (Integer) Playground.getGlobalFlag("points"); + Playground.setGlobalFlag("points", pts - 200); } applySpeedVector(); diff --git a/GameProject/src/controller/MineController.java b/GameProject/src/controller/MineController.java index 28a4348..5aa7e83 100644 --- a/GameProject/src/controller/MineController.java +++ b/GameProject/src/controller/MineController.java @@ -1,6 +1,5 @@ package controller; -import controller.ObjectController; import gameobjects.GameObject; import org.apache.logging.log4j.Logger; diff --git a/GameProject/src/gameobjects/AnimatedGameobject.java b/GameProject/src/gameobjects/AnimatedGameobject.java index 9105cca..571f59e 100644 --- a/GameProject/src/gameobjects/AnimatedGameobject.java +++ b/GameProject/src/gameobjects/AnimatedGameobject.java @@ -1,9 +1,7 @@ package gameobjects; -import java.util.LinkedList; import playground.Playground; import playground.Animation; -import collider.Collider; import collider.RectCollider; import rendering.*; import org.apache.logging.log4j.Logger; diff --git a/GameProject/src/gameobjects/EgoObject.java b/GameProject/src/gameobjects/EgoObject.java index b1e5043..442cbec 100644 --- a/GameProject/src/gameobjects/EgoObject.java +++ b/GameProject/src/gameobjects/EgoObject.java @@ -3,14 +3,6 @@ package gameobjects; import java.awt.Color; import collider.*; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.util.LinkedList; -import javax.imageio.ImageIO; -import collider.Collider; -import controller.ObjectController; import playground.Playground; import rendering.*; diff --git a/GameProject/src/gameobjects/FallingStar.java b/GameProject/src/gameobjects/FallingStar.java index 17af7b6..d5b0e1a 100644 --- a/GameProject/src/gameobjects/FallingStar.java +++ b/GameProject/src/gameobjects/FallingStar.java @@ -8,7 +8,6 @@ import rendering.*; public class FallingStar extends GameObject { - private Color color = Color.WHITE; protected double rad = -1; @@ -16,8 +15,7 @@ public class FallingStar extends GameObject { public FallingStar(String id, Playground playground, double x, double y, double vx, double vy, Color color, double rad) { super(id, playground, x, y, vx, vy); - this.rad = rad; - this.color = color; + this.rad = rad; LinkedList cols = new LinkedList(); CircleCollider cc = new CircleCollider("cc", this, rad); cols.add(cc); diff --git a/GameProject/src/gameobjects/RectObject.java b/GameProject/src/gameobjects/RectObject.java index 8009dc0..78efdb5 100644 --- a/GameProject/src/gameobjects/RectObject.java +++ b/GameProject/src/gameobjects/RectObject.java @@ -1,10 +1,8 @@ package gameobjects; import java.awt.Color; -import java.io.File; import collider.RectCollider; import playground.Playground; -import playground.SpaceInvadersLevel; import rendering.RectArtist; /** diff --git a/GameProject/src/gameobjects/TextObject.java b/GameProject/src/gameobjects/TextObject.java index c5263cb..30fca81 100644 --- a/GameProject/src/gameobjects/TextObject.java +++ b/GameProject/src/gameobjects/TextObject.java @@ -1,14 +1,8 @@ package gameobjects; import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics2D; -import java.awt.font.FontRenderContext; -import java.awt.font.TextAttribute; -import java.text.AttributedString; import java.util.LinkedList; import collider.*; -import controller.ObjectController; import playground.Playground; import rendering.*; diff --git a/GameProject/src/playground/Animation.java b/GameProject/src/playground/Animation.java index c1c12c6..5b658c0 100644 --- a/GameProject/src/playground/Animation.java +++ b/GameProject/src/playground/Animation.java @@ -38,7 +38,6 @@ public class Animation { String zeile; double zeit; - int it = 0; while (scanner.hasNext()) { if (scanner.hasNextDouble()) { @@ -57,7 +56,6 @@ public class Animation { logger.warn(file + " not found!!"); } - it++; logger.trace(basePath.getParent().toString() + "/" + zeile); } } diff --git a/GameProject/src/playground/LevelHitTwice.java b/GameProject/src/playground/LevelHitTwice.java index 241ae9e..f0fc782 100644 --- a/GameProject/src/playground/LevelHitTwice.java +++ b/GameProject/src/playground/LevelHitTwice.java @@ -1,11 +1,6 @@ package playground; -import controller.FallingStarController; -import gameobjects.EgoObject; -import gameobjects.FallingStar; import gameobjects.GameObject; -import gameobjects.RectObject; -import java.awt.Color; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/GameProject/src/playground/SpaceInvadersLevel.java b/GameProject/src/playground/SpaceInvadersLevel.java index 0d577ea..4d16fb5 100644 --- a/GameProject/src/playground/SpaceInvadersLevel.java +++ b/GameProject/src/playground/SpaceInvadersLevel.java @@ -1,6 +1,5 @@ package playground; -// import utilities.* ; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; @@ -237,7 +236,6 @@ public class SpaceInvadersLevel extends Playground { // check whether all enemies have been destroyed or escaped if (enemies.size() == 0) { - HighscoreManager hsm = new HighscoreManager(); HighscoreManager.writeHSToFile((Integer) Playground.getGlobalFlag("points"), (Integer) Playground.getGlobalFlag("highscore")); this.doneLevel = true; @@ -487,7 +485,6 @@ public class SpaceInvadersLevel extends Playground { } void createCollectables() { - double gameTime = this.getGameTime(); // create collectables for (int i = 0; i < this.calcNrCollect(); i++) { diff --git a/GameProject/src/playground/SpaceInvadersLevelTest.java b/GameProject/src/playground/SpaceInvadersLevelTest.java index 23c18f4..145028e 100644 --- a/GameProject/src/playground/SpaceInvadersLevelTest.java +++ b/GameProject/src/playground/SpaceInvadersLevelTest.java @@ -56,24 +56,24 @@ class SpaceInvadersLevelTest { @Test void testActionIfEnemyIsHitPointsUp() { - Integer numPointsBefore = (Integer)myLevel.getGlobalFlag("points"); + Integer numPointsBefore = (Integer)Playground.getGlobalFlag("points"); GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.WHITE); GameObject dummyEnemy = new RectObject("ego1", myLevel, 0,0,0,0, 12, 12, Color.BLACK); myLevel.addObject(dummyShot); myLevel.addObject(dummyEnemy); myLevel.actionIfEnemyIsHit(dummyEnemy, dummyShot);; // this is the call under test - Integer numPointsAfter = (Integer)myLevel.getGlobalFlag("points"); // changed? + Integer numPointsAfter = (Integer)Playground.getGlobalFlag("points"); // changed? assertTrue("numPoints is up +200 after EnemyIsHit", numPointsAfter == numPointsBefore + 200); // points are set +200 , check. } @Test void testActionIfEgoObjectIsHitLivesDown() { - Integer numLivesBefore = (Integer)myLevel.getGlobalFlag("egoLives"); + Integer numLivesBefore = (Integer)Playground.getGlobalFlag("egoLives"); GameObject dummyShot = new RectObject("shot1", myLevel, 0,0,0,0, 12, 12, Color.RED); GameObject dummyEgo = new EgoObject("ego1", myLevel, 0,0,0,0, 5); myLevel.addObject(dummyShot); myLevel.actionIfEgoObjectIsHit(dummyShot, dummyEgo); // this is the call under test - Integer numLivesAfter = (Integer)myLevel.getGlobalFlag("egoLives"); // changed? + Integer numLivesAfter = (Integer)Playground.getGlobalFlag("egoLives"); // changed? assertTrue("numLives is reduced by one ifEgoIsHit", numLivesAfter == numLivesBefore - 1); // lives is reduced by one } diff --git a/GameProject/src/rendering/RectArtist.java b/GameProject/src/rendering/RectArtist.java index e1ff70e..e6de3b6 100644 --- a/GameProject/src/rendering/RectArtist.java +++ b/GameProject/src/rendering/RectArtist.java @@ -23,8 +23,6 @@ public class RectArtist extends Artist { // g.drawLine((int) (Math.round(this.getX())), (int) (Math.round(this.getY()-this.height/2.)), // (int) Math.round(this.getX()), // (int) Math.round(this.getY() + this.height/2.)); - int x = (int) this.getX(); - int y = (int) this.getY(); g.fillRect((int) (this.getX() - this.width / 2.), (int) (this.getY() - this.height / 2.), (int) this.width, (int) this.height); diff --git a/GameProject/src/rendering/TextArtist.java b/GameProject/src/rendering/TextArtist.java index 5c312fd..4d33b45 100644 --- a/GameProject/src/rendering/TextArtist.java +++ b/GameProject/src/rendering/TextArtist.java @@ -14,14 +14,19 @@ import java.text.AttributedString; public class TextArtist extends Artist { private String text = null; - private int size = 1; private Color textColor = null; protected double textWidth, textHeight; Font serifFont = null; + /** Constructor to intitialize the TextArtist attributes + * + * @param go GameObject to be used for xy coordinate reference + * @param text the text to draw + * @param size point size to be used for font "Serif" + * @param textColor color to draw the text with (foreground) + */ public TextArtist(GameObject go, String text, int size, Color textColor) { super(go); - this.size = size; this.text = text; this.serifFont = new Font("Serif", Font.PLAIN, size); diff --git a/GameProject/src/ui/GameUI.java b/GameProject/src/ui/GameUI.java index beaad14..ff19226 100644 --- a/GameProject/src/ui/GameUI.java +++ b/GameProject/src/ui/GameUI.java @@ -1,6 +1,5 @@ package ui; -import java.awt.Dimension; import java.util.*; import javax.swing.JFrame; import javax.swing.JMenu; From d32fa9fa7eacabfc3b82da5d2dff4fca6fd37ae4 Mon Sep 17 00:00:00 2001 From: Kai Simon Date: Sun, 1 May 2022 22:01:42 +0200 Subject: [PATCH 3/4] test --- Kaigo | 1 + 1 file changed, 1 insertion(+) create mode 160000 Kaigo diff --git a/Kaigo b/Kaigo new file mode 160000 index 0000000..0bdbbf2 --- /dev/null +++ b/Kaigo @@ -0,0 +1 @@ +Subproject commit 0bdbbf29d0b510ff3a3693b87dce472929b417f1 From 398fafddd565e4beae2c4b900ea59bdd883301d8 Mon Sep 17 00:00:00 2001 From: Kai Simon Date: Sun, 1 May 2022 22:39:56 +0200 Subject: [PATCH 4/4] LOL --- Kaigo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kaigo b/Kaigo index 0bdbbf2..d1b3c1d 160000 --- a/Kaigo +++ b/Kaigo @@ -1 +1 @@ -Subproject commit 0bdbbf29d0b510ff3a3693b87dce472929b417f1 +Subproject commit d1b3c1db4d04b35d23f7bbc3297a76cf869b7a04