|
|
@ -26,7 +26,7 @@ public class LevelMovingHitObjects extends SpaceInvadersLevel { |
|
|
|
@Override |
|
|
|
public void prepareLevel(String id) { |
|
|
|
super.prepareLevel(id); |
|
|
|
|
|
|
|
Logger.trace("Creating and adding two RectObjects with Collider"); |
|
|
|
blueBox = new RectObject("fly_enemy1", this, 300, 300, 75, 40, 40, 40, Color.BLUE); |
|
|
|
this.addObject(blueBox); |
|
|
|
ReboundController boxControl = new ReboundController(); |
|
|
@ -40,15 +40,18 @@ public class LevelMovingHitObjects extends SpaceInvadersLevel { |
|
|
|
greenBox.addController(boxControl_2); |
|
|
|
RectCollider colliderGreen = new RectCollider("ColliderGreen", greenBox, 40, 40); |
|
|
|
greenBox.addCollider(colliderGreen); |
|
|
|
Logger.debug("successfully finished prepareLevel with two RectObjects"); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
void actionIfEgoCollidesWithEnemy(GameObject enemy, GameObject ego) { |
|
|
|
super.actionIfEgoCollidesWithEnemy(enemy, ego); |
|
|
|
if(enemy.id.contains("fly")) { |
|
|
|
this.lost = true; |
|
|
|
Playground.setGlobalFlag("egoLives", 0); |
|
|
|
Logger.info("ego hit a letal RectObject. Game ends NOW"); |
|
|
|
} else { |
|
|
|
Logger.debug("ego hit one of the other aliens, calling parent class code"); |
|
|
|
super.actionIfEgoCollidesWithEnemy(enemy, ego); |
|
|
|
|
|
|
|
HighscoreManager.writeHSToFile((Integer) Playground.getGlobalFlag("points"), |
|
|
|
(Integer) Playground.getGlobalFlag("highscore")); |
|
|
|