Nour 2 years ago
parent
commit
db59b895bc
  1. 3
      GameProject/src/base/BreakoutGame.java
  2. 67
      GameProject/src/playground/BreakoutLevel1.java

3
GameProject/src/base/BreakoutGame.java

@ -19,7 +19,8 @@ public class BreakoutGame extends GameLoop {
@Override
public void defineLevels() {
this.resetLevels(); // removes Level1 added by superclass constructor
// this.addLevel(new BreakoutLevel1()); // FIXME add this as soon as your level exists
this.addLevel(new BreakoutLevel1());
}
/**

67
GameProject/src/playground/BreakoutLevel1.java

@ -0,0 +1,67 @@
package playground;
import java.awt.Color;
import collider.RectCollider;
import controller.EgoController;
import controller.ReboundController;
import gameobjects.FallingStar;
import gameobjects.GameObject;
import gameobjects.RectObject;
public class BreakoutLevel1 extends BreakoutLevelBase{
@Override
protected void actionIfBallHitsBrick(GameObject ball, GameObject brick) {
// TODO Auto-generated method stub
}
@Override
protected void actionIfBallHitsEgo(GameObject ball, GameObject ego) {
// TODO Auto-generated method stub
}
@Override
protected GameObject createEgoObject() {
GameObject NewEgo = new RectObject("Ego", this, 350, 550, 0, 0, 80 , 10 , null);
NewEgo.addController(new EgoController(gameTime));
NewEgo.addCollider(new RectCollider("Ego", NewEgo, 80, 10));
return NewEgo;
}
@Override
protected GameObject createBall() {
GameObject Ball = new FallingStar("Ball", this, 350, 350, 120, 120, Color.red, 5);
Ball.addController(new ReboundController());
return Ball;
}
@Override
protected GameObject createBrick(int row, int column) {
GameObject Brick = new RectObject("brick", this, 40, 40, 0, 0, 60, 30, Color.green);
Brick.addCollider(new RectCollider("brick", Brick, 60, 30));
return Brick;
}
@Override
public void prepareLevel(String level) {
this.addObject(createEgoObject());
this.addObject(createBall());
this.addObject(createBrick(10, 3));
this.addObject(ball);
this.addObject(ego);
}
}
Loading…
Cancel
Save