Browse Source

solved HA03

master
fdai7303 3 years ago
parent
commit
772c4c0793
  1. 14
      GameProject/src/base/MultiLevelGame.java
  2. 47
      GameProject/src/playground/Level5.java
  3. 21
      GameProject/src/playground/Level6.java
  4. 24
      GameProject/src/playground/Level7.java

14
GameProject/src/base/MultiLevelGame.java

@ -4,6 +4,9 @@ import java.io.IOException;
import playground.Level1; import playground.Level1;
import playground.Level3; import playground.Level3;
import playground.Level5;
import playground.Level6;
import playground.Level7;
import playground.LevelBoss; import playground.LevelBoss;
import playground.LevelHitTwice; import playground.LevelHitTwice;
@ -12,10 +15,13 @@ public class MultiLevelGame extends GameLoop{
void defineLevels() { void defineLevels() {
this.resetLevels(); 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());
//this.addLevel(new Level1());
//this.addLevel(new LevelHitTwice());
//this.addLevel(new Level3());
//this.addLevel(new LevelBoss());
} }
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {

47
GameProject/src/playground/Level5.java

@ -0,0 +1,47 @@
package playground;
import java.awt.Color;
import gameobjects.GameObject;
public class Level5 extends SpaceInvadersLevel {
@Override
protected int calcNrEnemies() {
return 5;//SpaceInvadersLevel.NR_ENEMIES;
}
protected double calcEnemySpeedX() {
return 160;
}
protected double calcEnemySpeedY() {
return 80;
}
protected String getStartupMessage() {
return "Level 5, get ready!";
}
@Override
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);
//Enemy scream
System.out.println("AUA!");
}
}

21
GameProject/src/playground/Level6.java

@ -0,0 +1,21 @@
package playground;
public class Level6 extends SpaceInvadersLevel {
@Override
protected int calcNrEnemies() {
return 12;//SpaceInvadersLevel.NR_ENEMIES;
}
protected double calcEnemySpeedX() {
return 480;
}
protected double calcEnemySpeedY() {
return 80;
}
protected String getStartupMessage() {
return "Level 6, get ready!";
}
}

24
GameProject/src/playground/Level7.java

@ -0,0 +1,24 @@
package playground;
public class Level7 extends SpaceInvadersLevel {
@Override
protected int calcNrEnemies() {
return 21;//SpaceInvadersLevel.NR_ENEMIES;
}
@Override
protected double calcEnemySpeedX() {
return 800;
}
@Override
protected double calcEnemySpeedY() {
return 140;
}
@Override
protected String getStartupMessage() {
return "Level 7, get ready!";
}
}
Loading…
Cancel
Save