|
@ -0,0 +1,84 @@ |
|
|
|
|
|
package playground; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
|
|
|
|
import controller.BreakoutController; |
|
|
|
|
|
import controller.EgoController; |
|
|
|
|
|
import controller.ReboundController; |
|
|
|
|
|
import gameobjects.FallingStar; |
|
|
|
|
|
import gameobjects.GameObject; |
|
|
|
|
|
import gameobjects.RectObject; |
|
|
|
|
|
|
|
|
|
|
|
public class BreakoutLevel2 extends BreakoutLevelBaseAdvanced { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected int calcNrBricksX() { |
|
|
|
|
|
return 6; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected int calcNrBricksY() { |
|
|
|
|
|
return 5; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected double getBrickSizeX() { |
|
|
|
|
|
return 60; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected double getBrickSizeY() { |
|
|
|
|
|
return 30; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected double getBrickStartX() { |
|
|
|
|
|
return 90; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected double getBrickStartY() { |
|
|
|
|
|
return 60; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) { |
|
|
|
|
|
if(ball.collisionDetection(brick)) { |
|
|
|
|
|
ball.setVY(ball.getVY()*-1); |
|
|
|
|
|
deleteObjectNow(brick.id); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected void actionIfBallHitsEgo(GameObject ball, GameObject ego) { |
|
|
|
|
|
if(ball.collisionDetection(ego)) { |
|
|
|
|
|
ball.setVY(ball.getVY()*-1); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected GameObject createEgoObject() { |
|
|
|
|
|
RectObject ego = new RectObject("ego", this, 350, 550, 0, 0, 80, 10, Color.blue); |
|
|
|
|
|
this.addObject(ego); |
|
|
|
|
|
ego.addController(new BreakoutController(ego.getWidth(),ego.getHeight())); |
|
|
|
|
|
ego.addCollider(new collider.RectCollider(ego.getId(),ego,ego.getWidth(),ego.getHeight())); |
|
|
|
|
|
return ego; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected GameObject createBall() { |
|
|
|
|
|
gameobjects.FallingStar ball = new gameobjects.FallingStar("ball",this,350,350,130,130,Color.red,5); |
|
|
|
|
|
ball.addController(new ReboundController()); |
|
|
|
|
|
return ball; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
protected GameObject createBrick(int row, int column) { |
|
|
|
|
|
RectObject brick = new RectObject("brick"+row+column,this,40+(column*68),40+(row*60),0,0,60,30,Color.yellow); |
|
|
|
|
|
brick.addCollider(new collider.RectCollider(brick.getId(),brick,brick.getWidth(),brick.getHeight())); |
|
|
|
|
|
return brick; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |