diff --git a/.idea/artifacts/Programmieren_2_jar.xml b/.idea/artifacts/Programmieren_2_jar.xml index 889daac..f0cf1a4 100644 --- a/.idea/artifacts/Programmieren_2_jar.xml +++ b/.idea/artifacts/Programmieren_2_jar.xml @@ -1,5 +1,5 @@ - + $PROJECT_DIR$/out/artifacts/Programmieren_2_jar diff --git a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GameObjectManager.java b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GameObjectManager.java index 27f7834..6d1241b 100644 --- a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GameObjectManager.java +++ b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/game/managers/GameObjectManager.java @@ -1,10 +1,13 @@ package de.thdeg.greiner.superpangworld.game.managers; import de.thdeg.greiner.superpangworld.gameview.GameView; +import de.thdeg.greiner.superpangworld.graphics.base.Bubble; +import de.thdeg.greiner.superpangworld.graphics.base.GameObject; import de.thdeg.greiner.superpangworld.graphics.immovable.*; import de.thdeg.greiner.superpangworld.graphics.moveable.*; import java.awt.*; +import java.util.LinkedList; /** * The manager handling the display and passive movement of the game objects. @@ -15,10 +18,8 @@ class GameObjectManager { private GameView gameView; /** The game objects */ - private RoundBubble roundBubble; - private HexagonalBubble hexBubble; - private SpecialBubble specialBubble; - private Harpoon harpoon; + private LinkedList bubbles; + private LinkedList harpoons; private LevelProgressBar levelProgressBar; private LevelLabel levelLabel; private ScoreLabel scoreLabel; @@ -26,20 +27,25 @@ class GameObjectManager { private Background background; private Player player; + private LinkedList gameObjects; + /** * Create a manager handling the display and passive movement of the game objects. * @param gameView the GameView */ public GameObjectManager(GameView gameView){ this.gameView = gameView; - gameView.setColorForBlockImage('k', Color.LIGHT_GRAY); - this.roundBubble = new RoundBubble(gameView); - this.hexBubble = new HexagonalBubble(gameView); - this.specialBubble = new SpecialBubble(gameView); + bubbles = new LinkedList<>(); + harpoons = new LinkedList<>(); + gameObjects = new LinkedList<>(); - this.harpoon = new Harpoon(gameView); + bubbles.add(new RoundBubble(gameView)); + bubbles.add(new HexagonalBubble(gameView)); + bubbles.add(new SpecialBubble(gameView)); + + harpoons.add(new Harpoon(gameView)); this.levelProgressBar = new LevelProgressBar(gameView); this.levelLabel = new LevelLabel(gameView); @@ -57,22 +63,21 @@ class GameObjectManager { * Add the objects to the canvas and handle update their positions. */ public void updateGameObjects(){ - background.addToCanvas(); - roundBubble.updatePosition(); - roundBubble.addToCanvas(); - hexBubble.updatePosition(); - hexBubble.addToCanvas(); - specialBubble.updatePosition(); - specialBubble.addToCanvas(); - harpoon.updatePosition(); - harpoon.addToCanvas(); + gameObjects.clear(); + gameObjects.add(background); + gameObjects.addAll(bubbles); + gameObjects.addAll(harpoons); + gameObjects.add(levelProgressBar); + gameObjects.add(levelLabel); + gameObjects.add(scoreLabel); + gameObjects.add(livesIcon); + gameObjects.add(player); - levelProgressBar.addToCanvas(); - levelLabel.addToCanvas(); - scoreLabel.addToCanvas(); - livesIcon.addToCanvas(); - - player.addToCanvas(); + gameObjects.forEach(gameObject ->{ + gameObject.updatePosition(); + gameObject.updateStatus(); + gameObject.addToCanvas(); + }); } /** @@ -83,4 +88,19 @@ class GameObjectManager { return player; } + /** + * Get the bubbles. + * @return the bubbles + */ + public LinkedList getBubbles() { + return bubbles; + } + + /** + * Get the harpoons. + * @return the harpoons + */ + public LinkedList getHarpoons() { + return harpoons; + } } diff --git a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/base/GameObject.java b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/base/GameObject.java index b36bba7..a06e99c 100644 --- a/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/base/GameObject.java +++ b/SuperPangWorld/src/de/thdeg/greiner/superpangworld/graphics/base/GameObject.java @@ -49,6 +49,13 @@ public abstract class GameObject { } + /** + * Updates the game object's status. + */ + public void updateStatus(){ + + } + /** * Set the responsible GamePlayManager. * @param gamePlayManager the responsible GamePlayManager @@ -64,4 +71,5 @@ public abstract class GameObject { public Position getPosition(){ return position; } + } diff --git a/out/artifacts/Programmieren_2_jar/Programmieren 2.jar b/out/artifacts/Programmieren_2_jar/Programmieren 2.jar index d77d84d..c429177 100644 Binary files a/out/artifacts/Programmieren_2_jar/Programmieren 2.jar and b/out/artifacts/Programmieren_2_jar/Programmieren 2.jar differ