diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..b37a95c --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1,2 @@ +/playground/ +/base/ diff --git a/bin/base/MultiLevelGame.class b/bin/base/MultiLevelGame.class index b1d6dc3..7323e32 100644 Binary files a/bin/base/MultiLevelGame.class and b/bin/base/MultiLevelGame.class differ diff --git a/src/base/MultiLevelGame.java b/src/base/MultiLevelGame.java index e0a4962..ac8b0e8 100644 --- a/src/base/MultiLevelGame.java +++ b/src/base/MultiLevelGame.java @@ -8,6 +8,9 @@ import playground.Level1; import playground.Level3; import playground.LevelBoss; import playground.LevelHitTwice; +import playground.Level5; +import playground.Level6; +import playground.Level7; public class MultiLevelGame extends GameLoop{ @@ -25,6 +28,9 @@ public class MultiLevelGame extends GameLoop{ this.addLevel(new LevelHitTwice()); this.addLevel(new Level3()); this.addLevel(new LevelBoss()); + this.addLevel(new Level5()); + this.addLevel(new Level6()); + this.addLevel(new Level7()); } } diff --git a/src/playground/Level5.java b/src/playground/Level5.java new file mode 100644 index 0000000..4b838de --- /dev/null +++ b/src/playground/Level5.java @@ -0,0 +1,27 @@ +package playground; + + +/** + * extends {@link SpaceInvadersLevel} with a boring start message + */ +public class Level5 extends SpaceInvadersLevelAua { + + @Override + protected String getStartupMessage() { + return "Level5, get ready!"; + } + + @Override + protected int calcNrEnemies() { + return 5; + } + @Override + protected double calcEnemySpeedX() { + return 160; + } + @Override + protected double calcEnemySpeedY() { + return 80; + } + +} diff --git a/src/playground/Level6.java b/src/playground/Level6.java new file mode 100644 index 0000000..e97acb1 --- /dev/null +++ b/src/playground/Level6.java @@ -0,0 +1,27 @@ +package playground; + + +/** + * extends {@link SpaceInvadersLevel} with a boring start message + */ +public class Level6 extends SpaceInvadersLevelAua { + + @Override + protected String getStartupMessage() { + return "Level6, get ready!"; + } + + @Override + protected int calcNrEnemies() { + return 12; + } + @Override + protected double calcEnemySpeedX() { + return 480; + } + @Override + protected double calcEnemySpeedY() { + return 80; + } + +} diff --git a/src/playground/Level7.java b/src/playground/Level7.java new file mode 100644 index 0000000..d10d894 --- /dev/null +++ b/src/playground/Level7.java @@ -0,0 +1,27 @@ +package playground; + + +/** + * extends {@link SpaceInvadersLevel} with a boring start message + */ +public class Level7 extends SpaceInvadersLevelAua { + + @Override + protected String getStartupMessage() { + return "Level7, get ready!"; + } + @Override + protected int calcNrEnemies() { + return 21; + } + @Override + protected double calcEnemySpeedX() { + return 800; + } + @Override + protected double calcEnemySpeedY() { + return 140; + } + + +} diff --git a/src/playground/SpaceInvadersLevelAua.java b/src/playground/SpaceInvadersLevelAua.java new file mode 100644 index 0000000..8087f58 --- /dev/null +++ b/src/playground/SpaceInvadersLevelAua.java @@ -0,0 +1,73 @@ +package playground; + +// import utilities.* ; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.awt.RenderingHints; +import java.awt.font.TextAttribute; +import java.awt.image.BufferedImage; +import java.io.*; +import java.text.AttributedString; +import java.util.LinkedList; +import controller.EnemyController; +import controller.FallingStarController; +import controller.LimitedTimeController; +import controller.ObjectController; +import controller.EgoController; +import controller.CollisionAwareEgoController; +import gameobjects.AnimatedGameobject; +import gameobjects.FallingStar; +import gameobjects.GameObject; +import gameobjects.EgoObject; +import gameobjects.TextObject; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +/** + * Class that realizes all the game logic of a very simple game level. The level contains for now + * only two objects that are {@link GameObject} subclasses: {@link FallingStar} and + * {@link EgoObject}. Functions performed by this class are: + * + */ +public class SpaceInvadersLevelAua extends SpaceInvadersLevel { + + + /** + * implements game behavior if an enemy object is hit by a players' shot. It creates an explosion + * effect, plays a sound and adds 200 points to the current score (and it removes the enemy object + * and the shot object). + * + * @param e enemy which was hit + * @param shot the shot object that hit the enemy + */ + void actionIfEnemyIsHit(GameObject e, GameObject shot) { + + double gameTime = this.getGameTime(); + createExplosion(gameTime, e, "shard", DYING_INTERVAL, Color.RED); + + Music.music(smash); + + // delete enemy + deleteObject(e.getId()); + + // delete shot + deleteObject(shot.getId()); + + // add to points counter + Integer pts = (Integer) getGlobalFlag("points"); + setGlobalFlag("points", pts + 200); + + //print aua on console + System.out.println("AUA!!"); + + } + +}