Anna Schiedner
3 years ago
7 changed files with 162 additions and 0 deletions
-
2bin/.gitignore
-
BINbin/base/MultiLevelGame.class
-
6src/base/MultiLevelGame.java
-
27src/playground/Level5.java
-
27src/playground/Level6.java
-
27src/playground/Level7.java
-
73src/playground/SpaceInvadersLevelAua.java
@ -0,0 +1,2 @@ |
|||
/playground/ |
|||
/base/ |
@ -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; |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
|||
|
|||
} |
@ -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; |
|||
} |
|||
|
|||
|
|||
} |
@ -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!!"); |
|||
|
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue