Package playground
Class BreakoutLevelBaseAdvanced
java.lang.Object
playground.Playground
playground.BreakoutLevelBase
playground.BreakoutLevelBaseAdvanced
- Direct Known Subclasses:
BreakoutLevel2
Advanced version of abstract
BreakoutLevelBase
providing a complete implementation of
prepareLevel(String)
. Additionally abstract methods for number of bricks in X and Y
direction are provided as well as abstract methods for brick sizes and start coordinates.-
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 abstract int
provides the number of bricks to be set in horizontal direction.protected abstract int
provides the number of bricks to be set in vertical direction.protected abstract double
provides the length of one brick.protected abstract double
provides the height of one brick.protected abstract double
provides the start coordinate of upper left corner (X value).protected abstract double
provides the start coordinate of upper left corner (Y value).void
prepareLevel
(String level) Prepares a complete Breakout type level and uses the values provided by implementations ofcalcNrBricksX()
andcalcNrBricksY()
to generate the stone matrix.Methods inherited from class playground.BreakoutLevelBase
actionIfBallHitsBrick, actionIfBallHitsEgo, applyGameLogic, createBall, createBrick, createEgoObject, 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
-
BreakoutLevelBaseAdvanced
public BreakoutLevelBaseAdvanced()
-
-
Method Details
-
calcNrBricksX
protected abstract int calcNrBricksX()provides the number of bricks to be set in horizontal direction.- Returns:
- positive value of how many bricks are to be next to each other in X direction
-
calcNrBricksY
protected abstract int calcNrBricksY()provides the number of bricks to be set in vertical direction.- Returns:
- positive value of how many bricks are to be next to each other in Y direction
-
getBrickSizeX
protected abstract double getBrickSizeX()provides the length of one brick.- Returns:
- positive value of how long a brick should be in X direction.
-
getBrickSizeY
protected abstract double getBrickSizeY()provides the height of one brick.- Returns:
- positive value of how high a brick should be in Y direction.
-
getBrickStartX
protected abstract double getBrickStartX()provides the start coordinate of upper left corner (X value).- Returns:
- positive value of the X coordinate to use as the starting point of the upper left corner of the brick set.
-
getBrickStartY
protected abstract double getBrickStartY()provides the start coordinate of upper left corner (Y value).- Returns:
- positive value of the Y coordinate to use as the starting point of the upper left corner of the brick set.
-
prepareLevel
Prepares a complete Breakout type level and uses the values provided by implementations ofcalcNrBricksX()
andcalcNrBricksY()
to generate the stone matrix. Furthermore, it relies on the methodsBreakoutLevelBase.createEgoObject()
,BreakoutLevelBase.createBall()
andBreakoutLevelBase.createBrick(int, int)
, which are meant to be overwritten in subclasses.
Attention: For collision detection bricks created byBreakoutLevelBase.createBrick(int, int)
need to have the String 'brick' in ID.- Specified by:
prepareLevel
in classBreakoutLevelBase
- Parameters:
level
- String passes by the game engine (not used currently and can be ignored).- See Also:
-
for further information.
-