Browse Source

Levels added

master
Anna Schiedner 2 years ago
parent
commit
ed5440ac4c
  1. 2
      bin/.gitignore
  2. BIN
      bin/base/MultiLevelGame.class
  3. 6
      src/base/MultiLevelGame.java
  4. 27
      src/playground/Level5.java
  5. 27
      src/playground/Level6.java
  6. 27
      src/playground/Level7.java
  7. 73
      src/playground/SpaceInvadersLevelAua.java

2
bin/.gitignore

@ -0,0 +1,2 @@
/playground/
/base/

BIN
bin/base/MultiLevelGame.class

6
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());
}
}

27
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;
}
}

27
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;
}
}

27
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;
}
}

73
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:
* <ul>
* <li>initially set up the level, spawn all object etc., in method {@link #prepareLevel}
* <li>React to game events in {@link #actionIfEgoCollidesWithCollect(GameObject, GameObject)} ,
* {@link #actionIfEgoCollidesWithEnemy(GameObject, GameObject)}, etc.
* <li>define basic object movement rules for all objects in the level in the various
* ObjectController subclasses: {@link EgoController} and {@link FallingStarController}.
* </ul>
*/
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!!");
}
}
Loading…
Cancel
Save