package playground; import java.awt.Color; import gameobjects.*; import java.*; public class BreakoutLevel3 extends BreakoutLevel2 { @Override public void prepareLevel(String level) { this.setLevelFlag("points", 0); this.setGlobalFlag("lives", 3); TextObject points = new TextObject("Counter", this, 50D, 10D, 0D, 0D, "Points: "+ this.getLevelFlag("points").toString(), 20, Color.BLACK); this.addObject(points); TextObject lives = new TextObject ("Counter2", this, 600D, 10D, 0D, 0D, "Lives: "+ this.getGlobalFlag("lives").toString(), 20, Color.GREEN); this.addObject(lives); super.prepareLevel(level); } @Override protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) { super.actionIfBallHitsBrick(ball, brick); int newPoints = Integer.valueOf(this.getLevelFlag("points").toString()) + 10; this.setLevelFlag("points", newPoints); this.addObject(new TextObject("Counter", this, 50D, 10D, 0D, 0D, "Points: "+ this.getLevelFlag("points").toString(), 20, Color.BLACK)); } @Override public void applyGameLogic() { super.applyGameLogic(); if(this.ball.getY() < this.ego.getY()) { int newLives = Integer.valueOf(this.getGlobalFlag("lives").toString()) - 1; this.setGlobalFlag("points", newLives); this.addObject(new TextObject ("Counter2", this, 600D, 10D, 0D, 0D, "Lives: "+ this.getGlobalFlag("lives").toString(), 20, Color.GREEN)); } } }