You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
package playground;
|
|
|
|
import java.awt.Color;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
import controller.*;
|
|
import collider.RectCollider;
|
|
import gameobjects.FallingStar;
|
|
import gameobjects.GameObject;
|
|
import gameobjects.RectObject;
|
|
|
|
public class BreakoutLevel1 extends BreakoutLevelBase {
|
|
|
|
private static Logger logger = LogManager.getLogger(BreakoutLevel1.class);
|
|
|
|
@Override
|
|
protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) {
|
|
deleteObject(brick.getId());
|
|
ball.setVX(ball.getVX()*-1);
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
protected void actionIfBallHitsEgo(GameObject ball, GameObject ego) {
|
|
// TODO Auto-generated method stub
|
|
ball.setVY(ball.getVY()*-1);
|
|
|
|
}
|
|
|
|
@Override
|
|
protected GameObject createEgoObject() {
|
|
RectObject blueBox = new RectObject("ego", this, 350, 550, 0, 0, 80, 10, Color.BLUE);
|
|
blueBox.generateColliders();
|
|
EgoController ec = new EgoController(30);
|
|
blueBox.addController(ec);
|
|
logger.info("ego created.");
|
|
return blueBox;
|
|
}
|
|
|
|
@Override
|
|
protected GameObject createBall() {
|
|
GameObject ball = new FallingStar("ball1", this, 350, 350, 120, 120, Color.RED, 5);
|
|
ball.addController(new ReboundController());
|
|
logger.info("ball created.");
|
|
return ball;
|
|
}
|
|
|
|
@Override
|
|
protected GameObject createBrick(int row, int column) {
|
|
RectObject brick = new RectObject("brick"+row+column, this, 30 + row *60, 30 + column * 60, 0, 0, 40, 40, Color.GREEN);
|
|
brick.addCollider(new RectCollider("brickcoll"+row+column, brick, 40, 40));
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return brick;
|
|
}
|
|
|
|
@Override
|
|
public void prepareLevel(String level) {
|
|
GameObject ego1 = this.createEgoObject();
|
|
this.ego = ego1;
|
|
this.addObject(ego1);
|
|
|
|
|
|
GameObject ball1 = this.createBall();
|
|
this.ball = ball1;
|
|
this.addObject(ball1);
|
|
|
|
GameObject brick00 = this.createBrick(0, 0);
|
|
GameObject brick01 = this.createBrick(0, 1);
|
|
GameObject brick11 = this.createBrick(1, 1);
|
|
this.addObject(brick00);
|
|
this.addObject(brick01);
|
|
this.addObject(brick11);
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
}
|