Package playground
Class BreakoutLevel0
java.lang.Object
playground.Playground
playground.BreakoutLevelBase
playground.BreakoutLevel0
- Direct Known Subclasses:
BreakoutLevel3
simple solution example for Breakout game.
not implemented: penalty if balls hits ground, no score for removed bricks, no bonus items, no
lives.
-
Field Summary
Fields inherited from class playground.BreakoutLevelBase
ball, ego
Fields inherited from class playground.Playground
addables, canvasX, canvasY, flags, FLAGS_ALL, FLAGS_GLOBAL, FLAGS_LEVEL, gameObjects, gameTime, keyEvents, level, mouseEvents, pausedFlag, removables, timeStep
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
actionIfBallHitsBrick
(GameObject ball, GameObject brick) lets ball bounce in Y direction, deletes brick.protected void
actionIfBallHitsEgo
(GameObject ball, GameObject ego) Let the ball bounce off in Y direction.protected GameObject
Creates the ball object and returns it, called by #prepareLevel.protected GameObject
createBrick
(int row, int column) creates one brick.protected GameObject
Creates the ego object and returns it, called byBreakoutLevelBase.prepareLevel(java.lang.String)
.void
prepareLevel
(String level) Prepares a Breakout level with a 3 x 3 matrix of blocks on top.Methods inherited from class playground.BreakoutLevelBase
applyGameLogic, gameOver, levelFinished, preferredSizeX, preferredSizeY, redrawLevel, resetRequested
Methods inherited from class playground.Playground
addObject, addObjectNow, collectObjects, deleteObject, deleteObjectNow, getGameTime, getGlobalFlag, getKeyEvents, getLevelFlag, getMouseEvents, getObject, getOrCreateGlobalFlag, getOrCreateLevelFlag, getSizeX, getSizeY, getTimestep, isPaused, processKeyEvents, processMouseEvents, redraw, reset, resetFlags, setGameTime, setGlobalFlag, setLevelFlag, setPaused, setTimestep, togglePause, updateObjects
-
Constructor Details
-
BreakoutLevel0
public BreakoutLevel0()
-
-
Method Details
-
createEgoObject
Description copied from class:BreakoutLevelBase
Creates the ego object and returns it, called byBreakoutLevelBase.prepareLevel(java.lang.String)
. Does NOT add the ego object to the playground, but returns it.- Specified by:
createEgoObject
in classBreakoutLevelBase
- Returns:
- The created ego object instance (of class
RectObject
withEgoController
.
-
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 classBreakoutLevelBase
- Returns:
- The created ball object instance (of class
FallingStar
)
-
createBrick
creates one brick. For collisionRectCollider
is used.- Specified by:
createBrick
in classBreakoutLevelBase
- Parameters:
row
- row position in the grid, ranges from 0 to calcNrBricksY()-1column
- 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
lets ball bounce in Y direction, deletes brick.- Specified by:
actionIfBallHitsBrick
in classBreakoutLevelBase
- Parameters:
ball
- A reference to the current ball objectbrick
- A reference to the ego object
-
actionIfBallHitsEgo
Let the ball bounce off in Y direction.- Specified by:
actionIfBallHitsEgo
in classBreakoutLevelBase
- Parameters:
ball
- A reference to the current ball objectego
- A reference to the ego object
-
prepareLevel
Prepares a Breakout level with a 3 x 3 matrix of blocks on top. This method relies on the methods#createEgo
,createBall()
andcreateBrick(int, int)
, among others.- Specified by:
prepareLevel
in classBreakoutLevelBase
- Parameters:
level
- String passes by the game engine (not used currently and can be ignored).
-