|
|
@ -1,24 +1,24 @@ |
|
|
|
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); |
|
|
|
super.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); |
|
|
|
TextObject lives = new TextObject("Counter2", this, 600D, 10D, 0D, 0D, "Lives: "+ super.getGlobalFlag("lives").toString(), 20, Color.GREEN); |
|
|
|
this.addObject(lives); |
|
|
|
|
|
|
|
super.prepareLevel(level); |
|
|
|
|
|
|
|
} |
|
|
@ -33,17 +33,12 @@ public class BreakoutLevel3 extends BreakoutLevel2 { |
|
|
|
@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)); |
|
|
|
if(ball.getY() > ego.getY()) { |
|
|
|
int newLives = Integer.valueOf(super.getGlobalFlag("lives").toString()) - 1; |
|
|
|
super.setGlobalFlag("newLives", newLives); |
|
|
|
this.addObject(new TextObject("Counter2", this, 600D, 10D, 0D, 0D, "Lives: "+ super.getGlobalFlag("newLives").toString(), 20, Color.GREEN)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|