diff --git a/GameProject/src/base/MovingObjectsGame.java b/GameProject/src/base/MovingObjectsGame.java
index ab52fec..93ec2ad 100644
--- a/GameProject/src/base/MovingObjectsGame.java
+++ b/GameProject/src/base/MovingObjectsGame.java
@@ -1,13 +1,17 @@
package base;
import java.io.IOException;
-import playground.LevelMovingObjects;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import playground.*;
/**
* main class to start a game with only one level {@link playground.LevelMovingObjects}.
*
*/
public class MovingObjectsGame extends GameLoop {
+
+ private static Logger logger = LogManager.getLogger(MovingObjectsGame.class);
/**
* starts this game.
@@ -17,6 +21,7 @@ public class MovingObjectsGame extends GameLoop {
* thrown (and game ends).
*/
public static void main(String[] args) throws IOException {
+ logger.info("Starting Game Program...let's play and don't get hit!");
GameLoop myGame = new MovingObjectsGame();
myGame.runGame(args);
}
@@ -27,7 +32,7 @@ public class MovingObjectsGame extends GameLoop {
@Override
public void defineLevels() {
this.resetLevels();
- this.addLevel(new LevelMovingObjects());
+ this.addLevel(new LevelMovingHitObjects());
}
}
diff --git a/GameProject/src/controller/ReboundController2.java b/GameProject/src/controller/ReboundController2.java
new file mode 100644
index 0000000..1bee573
--- /dev/null
+++ b/GameProject/src/controller/ReboundController2.java
@@ -0,0 +1,35 @@
+package controller;
+
+/** Controller to let Objects bounce from the outer level limits back and forth.
+ *
+ */
+public class ReboundController2 extends ObjectController {
+
+ /** inverts the x y direction speeds if the outer limits are reached.
+ *
+ */
+ @Override
+ public void updateObject() {
+ double sizeX = this.getPlayground().preferredSizeX();
+ double sizeY = this.getPlayground().preferredSizeY();
+ double objSizeX = 30;
+ double objSizeY = 30;
+
+ if (this.getX() < objSizeX) {
+ this.setVX(this.getVX() * -1);
+ this.setX(objSizeX);
+ } else if (this.getX() > sizeX - objSizeX) {
+ this.setVX(this.getVX() * -1);
+ this.setX(sizeX - objSizeX);
+ }
+ if (this.getY() < objSizeY) {
+ this.setVY(this.getVY() * -1);
+ this.setY(objSizeY);
+ } else if (this.getY() > sizeY - objSizeY) {
+ this.setVY(this.getVY() * -1);
+ this.setY(sizeY - objSizeY);
+ }
+ this.applySpeedVector();
+ }
+
+}
diff --git a/GameProject/src/log4j2.xml b/GameProject/src/log4j2.xml
index 21a7607..f21f70a 100644
--- a/GameProject/src/log4j2.xml
+++ b/GameProject/src/log4j2.xml
@@ -25,6 +25,6 @@
-
+
\ No newline at end of file
diff --git a/GameProject/src/playground/LevelMovingHitObjects.java b/GameProject/src/playground/LevelMovingHitObjects.java
new file mode 100644
index 0000000..533b41a
--- /dev/null
+++ b/GameProject/src/playground/LevelMovingHitObjects.java
@@ -0,0 +1,28 @@
+package playground;
+
+
+/**
+ * Level that creates two RectObjects moving around and if ego is hit by them game is directly lost
+ * (lives = 0).
+ *
+ */
+public class LevelMovingHitObjects extends SpaceInvadersLevel {
+
+ // FIXME add logger here
+
+
+ //FIXME add your method overrides here
+
+
+
+ /**
+ * "Moving Hitting Objects Level!" is the message.
+ *
+ * @return String "Moving & Hitting Objects Level!"
+ */
+ @Override
+ protected String getStartupMessage() {
+ return "Moving & Hitting Objects Level!";
+ }
+
+}
diff --git a/GameProject/src/playground/package-info.java b/GameProject/src/playground/package-info.java
index bbbf357..972351d 100644
--- a/GameProject/src/playground/package-info.java
+++ b/GameProject/src/playground/package-info.java
@@ -2,7 +2,7 @@
* 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}).
+ * 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.
*/