From 01bb10e5dc01637ad7662e05ad0dc7c1170d26be Mon Sep 17 00:00:00 2001 From: Nico B Date: Thu, 12 May 2022 14:15:34 +0200 Subject: [PATCH] HA04 finished --- GameProject/src/base/MultiLevelGame.java | 15 ++++------ GameProject/src/playground/LevelWithBox.java | 30 ++++++++++++++++++++ GameProject/src/playground/Playground.java | 3 +- 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 GameProject/src/playground/LevelWithBox.java diff --git a/GameProject/src/base/MultiLevelGame.java b/GameProject/src/base/MultiLevelGame.java index 8d564b8..4f2055c 100644 --- a/GameProject/src/base/MultiLevelGame.java +++ b/GameProject/src/base/MultiLevelGame.java @@ -2,13 +2,7 @@ package base; import java.io.IOException; -import playground.Level1; -import playground.Level3; -import playground.Level5; -import playground.Level6; -import playground.Level7; -import playground.LevelBoss; -import playground.LevelHitTwice; +import playground.*; public class MultiLevelGame extends GameLoop { @@ -27,9 +21,10 @@ public class MultiLevelGame extends GameLoop { //this.addLevel(new Level3()); //this.addLevel(new LevelBoss()); - this.addLevel(new Level5()); - this.addLevel(new Level6()); - this.addLevel(new Level7()); + //this.addLevel(new Level5()); + //this.addLevel(new Level6()); + //this.addLevel(new Level7()); + this.addLevel(new LevelWithBox()); } diff --git a/GameProject/src/playground/LevelWithBox.java b/GameProject/src/playground/LevelWithBox.java new file mode 100644 index 0000000..5b4a2a2 --- /dev/null +++ b/GameProject/src/playground/LevelWithBox.java @@ -0,0 +1,30 @@ +package playground; +import java.awt.Color; +import gameobjects.*; + +/** This class adds a new level to the game. + * + * @author team22 + */ +public class LevelWithBox extends SpaceInvadersLevel { + + /** This method overrides the initial method and adds a red rectangle on the top which does not do anything. + * + * @param id String identifies level + */ + @Override + public void prepareLevel(String id) { + super.prepareLevel(id); + RectObject rectangle = new RectObject("rectangle", this, 350, 100, 0, 0, 700, 250, Color.RED); + addObject(rectangle); + } + + /** This method overrides the initial method to change the startup message. + * + * @return String Startup message + */ + @Override + protected String getStartupMessage() { + return "Box-Level!"; + } +} diff --git a/GameProject/src/playground/Playground.java b/GameProject/src/playground/Playground.java index 6346d60..62532ab 100644 --- a/GameProject/src/playground/Playground.java +++ b/GameProject/src/playground/Playground.java @@ -81,6 +81,7 @@ public abstract class Playground { public void addObjectNow(GameObject o) { gameObjects.put(o.getId(), o); } + /** @@ -109,6 +110,7 @@ public abstract class Playground { } return l; }; + /** @@ -275,7 +277,6 @@ public abstract class Playground { return this.mouseEvents; } - /** * Method meant to be filled with own code, handles the entore game logic (collision checks, timed * events, ...).