Package playground

Class BreakoutLevel0

Direct Known Subclasses:
BreakoutLevel3

public class BreakoutLevel0 extends BreakoutLevelBase
simple solution example for Breakout game. not implemented: penalty if balls hits ground, no score for removed bricks, no bonus items, no lives.
  • Constructor Details

    • BreakoutLevel0

      public BreakoutLevel0()
  • Method Details

    • createEgoObject

      protected GameObject createEgoObject()
      Description copied from class: BreakoutLevelBase
      Creates the ego object and returns it, called by BreakoutLevelBase.prepareLevel(java.lang.String). Does NOT add the ego object to the playground, but returns it.
      Specified by:
      createEgoObject in class BreakoutLevelBase
      Returns:
      The created ego object instance (of class RectObject with EgoController.
    • createBall

      protected GameObject createBall()
      Description copied from class: BreakoutLevelBase
      Creates the ball object and returns it, called by #prepareLevel. Does NOT add the ball object to the playground, but returns it.
      Specified by:
      createBall in class BreakoutLevelBase
      Returns:
      The created ball object instance (of class FallingStar)
    • createBrick

      protected GameObject createBrick(int row, int column)
      creates one brick. For collision RectCollider is used.
      Specified by:
      createBrick in class BreakoutLevelBase
      Parameters:
      row - row position in the grid, ranges from 0 to calcNrBricksY()-1
      column - column position in the grid of bricks, ranges from 0 to calcNrBricksX()-1
      Returns:
      The GameObject instance (really a RectObject) representing the created brick.
    • actionIfBallHitsBrick

      protected void actionIfBallHitsBrick(GameObject ball, GameObject brick)
      lets ball bounce in Y direction, deletes brick.
      Specified by:
      actionIfBallHitsBrick in class BreakoutLevelBase
      Parameters:
      ball - A reference to the current ball object
      brick - A reference to the ego object
    • actionIfBallHitsEgo

      protected void actionIfBallHitsEgo(GameObject ball, GameObject ego)
      Let the ball bounce off in Y direction.
      Specified by:
      actionIfBallHitsEgo in class BreakoutLevelBase
      Parameters:
      ball - A reference to the current ball object
      ego - A reference to the ego object
    • prepareLevel

      public void prepareLevel(String level)
      Prepares a Breakout level with a 3 x 3 matrix of blocks on top. This method relies on the methods #createEgo, createBall() and createBrick(int, int), among others.
      Specified by:
      prepareLevel in class BreakoutLevelBase
      Parameters:
      level - String passes by the game engine (not used currently and can be ignored).