Browse Source

Hausaufgabe 4 Ergebnis

main
Manu 2 years ago
parent
commit
f01001a553
  1. 3
      GameProject/src/base/GameLoop.java
  2. 38
      GameProject/src/base/MultiLevelGame.java
  3. 43
      GameProject/src/playground/LevelWithBox.java
  4. 1
      GameProject/src/playground/Playground.java

3
GameProject/src/base/GameLoop.java

@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import gameobjects.GameObject;
import playground.Level1;
import playground.LevelWithBox;
import playground.Playground;
import ui.GameUI;
@ -55,7 +56,7 @@ public class GameLoop {
*/
void defineLevels() {
this.resetLevels();
this.addLevel(new Level1());
this.addLevel(new LevelWithBox());
}
/**

38
GameProject/src/base/MultiLevelGame.java

@ -2,29 +2,21 @@ package base;
import java.io.IOException;
import playground.*;
import playground.Level5;
import playground.LevelWithBox;
public class MultiLevelGame extends GameLoop {
@Override
void defineLevels() {
this.resetLevels();
//this.addLevel(new Level1());
// this.addLevel(new LevelHitTwice());
// this.addLevel(new Level3());
// this.addLevel(new LevelBoss());
this.addLevel(new Level5());
this.addLevel(new Level6());
this.addLevel(new Level7());
}
public static void main(String[] args) throws IOException {
MultiLevelGame l5 = new MultiLevelGame();
l5.runGame(args);
}
}
void defineLevels() {
this.addLevel(new LevelWithBox());
}
public static void main(String[] args) throws IOException {
GameLoop gl = new GameLoop();
gl.runGame(args);
}
}

43
GameProject/src/playground/LevelWithBox.java

@ -0,0 +1,43 @@
package playground;
import gameobjects.RectObject;
import java.awt.Color;
/**
* The class creates its own level, which contains 2 methods
* and takes methods from the SpaceInvadersLevel class as well as
* from the RectObject class.The graphical content is changed here.
* RectObject initialized with a suitable RectArtist to draw the RectObject.
*
* This class extends from {@link SpaceInvadersLife}.
*/
public class LevelWithBox extends SpaceInvadersLevel {
/**
*
* PrepareLevel
* First sets up the layer and calls it every time it starts.
* An object with transmitted parameters from RectObject is created.
* addObject Method from the {@link Playground} class adds the graphics object to a level.
* @param id - String unique name to be used.
*/
public void prepareLevel(String id) {
super.prepareLevel(id);
RectObject Object = new RectObject(id,null,350,100,0,0,700,250,Color.RED);
this.addObject(Object);
}
/**
* Returns the text that should be displayed at the beginning of the game.
*
* @return a string that is displayed at the beginning. It should be not longer than 30 characters.
*/
protected String getStartupMessage() {
return "Box-Level!";
}
}

1
GameProject/src/playground/Playground.java

@ -76,7 +76,6 @@ public abstract class Playground {
/**
* Adds a graphics object to a level.
*
* @param o GameObject The object to be added
*/
public void addObjectNow(GameObject o) {
gameObjects.put(o.getId(), o);

Loading…
Cancel
Save