Package playground
Class BreakoutLevelBase
java.lang.Object
playground.Playground
playground.BreakoutLevelBase
- Direct Known Subclasses:
BreakoutLevel1
-
Field Summary
Fields inherited from class playground.Playground
FLAGS_ALL, FLAGS_GLOBAL, FLAGS_LEVEL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
checks for interactions between GameObjects; notably ball with ego and ball with brick.boolean
gameOver()
signals to game engine that the game has finished by game over. called every game loop. default implementation is always false.boolean
signals to game engine that the game has finished by success. called every game loop. default implementation is always false.int
Signal that the level has a size of 700x700 pixels.int
Signal that the level has a size of 700x700 pixels.abstract void
prepareLevel
(String level) Prepares a generic Breakout-Type level.void
unimplemented empty method called by game engine every loop.boolean
signals to game engine that the game has been requested to be reseted (restart). called every game loop. default implementation is always false.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
-
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 classPlayground
- 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 classPlayground
- 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
unimplemented empty method called by game engine every loop.- Specified by:
redrawLevel
in classPlayground
- 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 classPlayground
- Returns:
- x size of level 700
-
preferredSizeY
public int preferredSizeY()Signal that the level has a size of 700x700 pixels.- Specified by:
preferredSizeY
in classPlayground
- 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 eitheractionIfBallHitsBrick(GameObject, GameObject)
oractionIfBallHitsEgo(GameObject, GameObject)
. Called every game loop.- Specified by:
applyGameLogic
in classPlayground
-
prepareLevel
Prepares a generic Breakout-Type level. This method relies on the methodscreateEgoObject()
,createBall()
andcreateBrick(int, int)
, among others, which are meant to be overwritten in subclasses.
Attention: the attributesball
andego
need to be set properly to GameObject instances when implementing this methodprepareLevel(String)
.- Specified by:
prepareLevel
in classPlayground
- Parameters:
level
- String passes by the game engine (not used currently and can be ignored).
-