Package playground

Class BreakoutLevelBase

java.lang.Object
playground.Playground
playground.BreakoutLevelBase
Direct Known Subclasses:
BreakoutLevel1

public abstract class BreakoutLevelBase extends Playground
  • Constructor Details

    • BreakoutLevelBase

      public BreakoutLevelBase()
  • Method Details

    • gameOver

      public boolean gameOver()
      signals to game engine that the game has finished by game over. called every game loop. default implementation is always false.
      Specified by:
      gameOver in class Playground
      Returns:
      false
    • levelFinished

      public boolean levelFinished()
      signals to game engine that the game has finished by success. called every game loop. default implementation is always false.
      Specified by:
      levelFinished in class Playground
      Returns:
      false
    • resetRequested

      public boolean resetRequested()
      signals to game engine that the game has been requested to be reseted (restart). called every game loop. default implementation is always false.
      Returns:
      false
    • redrawLevel

      public void redrawLevel(Graphics2D g)
      unimplemented empty method called by game engine every loop.
      Specified by:
      redrawLevel in class Playground
      Parameters:
      g - Graphics2D abstract drawing object of java Swing, used to carry out all drawing operations.
    • preferredSizeX

      public int preferredSizeX()
      Signal that the level has a size of 700x700 pixels.
      Specified by:
      preferredSizeX in class Playground
      Returns:
      x size of level 700
    • preferredSizeY

      public int preferredSizeY()
      Signal that the level has a size of 700x700 pixels.
      Specified by:
      preferredSizeY in class Playground
      Returns:
      y size of level 700
    • applyGameLogic

      public void applyGameLogic()
      checks for interactions between GameObjects; notably ball with ego and ball with brick. In case of detected collisions, it calls either actionIfBallHitsBrick(GameObject, GameObject) or actionIfBallHitsEgo(GameObject, GameObject). Called every game loop.
      Specified by:
      applyGameLogic in class Playground
    • prepareLevel

      public abstract void prepareLevel(String level)
      Prepares a generic Breakout-Type level. This method relies on the methods createEgoObject(), createBall() and createBrick(int, int), among others, which are meant to be overwritten in subclasses.
      Attention: the attributes ball and ego need to be set properly to GameObject instances when implementing this method prepareLevel(String).
      Specified by:
      prepareLevel in class Playground
      Parameters:
      level - String passes by the game engine (not used currently and can be ignored).