From 6db3f15fc8e785c203a0369fb6e04c786ec1d44d Mon Sep 17 00:00:00 2001 From: jkonert Date: Thu, 12 May 2022 10:05:42 +0200 Subject: [PATCH 1/5] added *.prefs to ignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0299504..806b528 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.DS_Store *.metadata/ *.class +*.prefs /GameProject/doc/ /GameProject/log/ /GameProject/highscore.txt From 35cfe32ba46b1bfd8cf96ad47702453b06363be3 Mon Sep 17 00:00:00 2001 From: jkonert Date: Thu, 12 May 2022 10:06:29 +0200 Subject: [PATCH 2/5] fixed some JavaDoc problems, especially German Umlauts on MacOs (encoding of files problem...should be UTF-8) --- GameProject/src/controller/EgoController.java | 15 +++------------ GameProject/src/playground/Level4.java | 4 ++-- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/GameProject/src/controller/EgoController.java b/GameProject/src/controller/EgoController.java index 45890b5..e00877a 100644 --- a/GameProject/src/controller/EgoController.java +++ b/GameProject/src/controller/EgoController.java @@ -165,23 +165,14 @@ public class EgoController extends ObjectController { released = false; } - /** - * Generelle Idee: Wenn eine Taste gedrückt wird wird sie gespeichert. wenn die zuvor - * gespeicherte Taste wieder losgelassen wird stoppt das Ego-Objekt. Falls vor dem Loslassen - * eine andere Taste gedrückt wird, wird diese gespeichert und die alte vergessen. Dh das - * loslassen der alten Taste stoppt das Objekt nicht. Spezialfall: space, das loslassen von - * space stoppt das Objekt nicht! - */ if (pressed == true) { lastPressedKey = pressedKey; pressedKey = kc; } - /** - * Nur eine losgelassene Taste die auch vorher gedrückt wurde stoppt das Objekt. Eine - * losgelassene Taste die nicht vorher gedrückt wurde bzw vergessen wurde stoppt das Objekt - * nicht + /* + * Only if the released key is the same as the before pressed one, it stops the ego object movement. */ if (released == true) { if (pressedKey != null) { @@ -219,7 +210,7 @@ public class EgoController extends ObjectController { // shot if (kc == KeyEvent.VK_SPACE) { - // space is not registered! Releasing space does not stop the egoobject + // space is not registered! Releasing space does not stop the ego object this.onSpace(e, ego); } } diff --git a/GameProject/src/playground/Level4.java b/GameProject/src/playground/Level4.java index d2bac0b..dacfd4f 100644 --- a/GameProject/src/playground/Level4.java +++ b/GameProject/src/playground/Level4.java @@ -10,14 +10,14 @@ import org.apache.logging.log4j.Logger; /** - * extends {@link SpaceInvadersLevel} + * extends {@link SpaceInvadersLevel} with aliens that need two hits to be destroyed. * */ public class Level4 extends SpaceInvadersLevel { - + /** constant defining the number of shots needed to destroy an enemy */ public static final int MAX_HITS = 2; From b07f813a1508a558e0549d79e46de3ef84c1db75 Mon Sep 17 00:00:00 2001 From: jkonert Date: Thu, 12 May 2022 13:40:04 +0200 Subject: [PATCH 3/5] HA05 base files added --- GameProject/src/base/MovingObjectsGame.java | 33 +++++++++++++++++++ .../src/playground/LevelMovingObjects.java | 21 ++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 GameProject/src/base/MovingObjectsGame.java create mode 100644 GameProject/src/playground/LevelMovingObjects.java diff --git a/GameProject/src/base/MovingObjectsGame.java b/GameProject/src/base/MovingObjectsGame.java new file mode 100644 index 0000000..ab52fec --- /dev/null +++ b/GameProject/src/base/MovingObjectsGame.java @@ -0,0 +1,33 @@ +package base; + +import java.io.IOException; +import playground.LevelMovingObjects; + +/** + * main class to start a game with only one level {@link playground.LevelMovingObjects}. + * + */ +public class MovingObjectsGame extends GameLoop { + + /** + * starts this game. + * + * @param args command line parameters (forwarded to {@link GameLoop#runGame(String[])}). + * @throws IOException if highscore.txt file cannot be written or accessed, the exception is + * thrown (and game ends). + */ + public static void main(String[] args) throws IOException { + GameLoop myGame = new MovingObjectsGame(); + myGame.runGame(args); + } + + /** + * adds only one level to play ({@link playground.LevelMovingObjects}). + */ + @Override + public void defineLevels() { + this.resetLevels(); + this.addLevel(new LevelMovingObjects()); + } + +} diff --git a/GameProject/src/playground/LevelMovingObjects.java b/GameProject/src/playground/LevelMovingObjects.java new file mode 100644 index 0000000..dd93acf --- /dev/null +++ b/GameProject/src/playground/LevelMovingObjects.java @@ -0,0 +1,21 @@ +package playground; + + + +/** This level adds two distracting objects to the canvas that cannot collide but bounce around all the time. + */ +public class LevelMovingObjects extends SpaceInvadersLevel { + + // TODO your code here + + + /** "Moving Objects Level!" is the message. + * + * @return String "Moving Objects Level!" + */ + @Override + protected String getStartupMessage() { + return "Moving Objects Level!"; + } +} + From bcf9a6d7f2fedb5a18f20e18dec4d85f08f99758 Mon Sep 17 00:00:00 2001 From: jkonert Date: Mon, 16 May 2022 16:08:27 +0200 Subject: [PATCH 4/5] added package descriptions for JavaDoc --- GameProject/src/collider/package-info.java | 9 +++++++++ GameProject/src/gameobjects/package-info.java | 7 +++++++ GameProject/src/playground/package-info.java | 9 +++++++++ 3 files changed, 25 insertions(+) create mode 100644 GameProject/src/collider/package-info.java create mode 100644 GameProject/src/gameobjects/package-info.java create mode 100644 GameProject/src/playground/package-info.java diff --git a/GameProject/src/collider/package-info.java b/GameProject/src/collider/package-info.java new file mode 100644 index 0000000..f101edb --- /dev/null +++ b/GameProject/src/collider/package-info.java @@ -0,0 +1,9 @@ +/** + * The package contains classes implementing a 'bounding box' area around game objects.
+ * The abstract base class {@link Collider} provides the abstract method {@link Collider#collidesWith(Collider)}, + * which needs to be implemented by child classes to detect and decide whether or not an object with such instance really collides with the other. + * {@link Collider} instances are to be used for game objects ({@link gameobjects}); see constructors.
+ * + * The benefit of seperating Colliders from visual representations is that the area for collisions can be smaller/bigger/other shape to improve game play experience. + */ +package collider; diff --git a/GameProject/src/gameobjects/package-info.java b/GameProject/src/gameobjects/package-info.java new file mode 100644 index 0000000..7ec704e --- /dev/null +++ b/GameProject/src/gameobjects/package-info.java @@ -0,0 +1,7 @@ +/** + * The package gameobjects contains all objects with a visual representation on screen. + * They can be combined to use controller instances for their behavior (subclasses of {@link controller.ObjectController}). + * The abstract base class is {@link GameObject}, which forces child-classes to implement the method + * {@link GameObject#updateObject()}. + */ +package gameobjects; diff --git a/GameProject/src/playground/package-info.java b/GameProject/src/playground/package-info.java new file mode 100644 index 0000000..bbbf357 --- /dev/null +++ b/GameProject/src/playground/package-info.java @@ -0,0 +1,9 @@ +/** + * The package playground contains all level specific logic and control of level logic. + * The structure and general logic (with global and local flags to be stored/used) + * is provided in abstract base class {@link Playground}.
+ * Child-classes implement specific logic for one level and game type (e.g. {@link SpaceInvadersLevel}). + * + * Generally, the base class {@link Playground} supports totally different game types to be implemented. + */ +package playground; From 1da5ebb4decd871493a6e1ae6788bccbd183f2bb Mon Sep 17 00:00:00 2001 From: jkonert Date: Mon, 16 May 2022 16:08:56 +0200 Subject: [PATCH 5/5] fixed inconsistency in ObjectController setting VX and VY of gameobject --- GameProject/src/controller/ObjectController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameProject/src/controller/ObjectController.java b/GameProject/src/controller/ObjectController.java index dd16f16..65478f2 100644 --- a/GameProject/src/controller/ObjectController.java +++ b/GameProject/src/controller/ObjectController.java @@ -56,7 +56,7 @@ public abstract class ObjectController { public void applySpeedVector() { double ts = this.getPlayground().getTimestep(); this.setX(this.getX() + this.getVX() * ts); - gameObject.setY(this.getY() + this.getVY() * ts); + this.setY(this.getY() + this.getVY() * ts); }