Package break_out.model
Class Level
- java.lang.Object
-
- java.lang.Thread
-
- break_out.model.Level
-
-
Field Summary
Fields Modifier and Type Field Description private Ball
ball
The ball of the levelprivate boolean
ballWasStarted
Flag that shows if the ball was startedprivate Game
game
The game to which the level belongsprivate boolean
levelFinished
Flag that shows if the level was finishedprivate int
levelnr
The number of the levelprivate int
lifeCounter
The life counter of the levelprivate Paddle
paddleBottom
The paddles of the levelprivate Paddle
paddleTop
The paddles of the levelprivate int
score
The score of the levelprivate java.util.ArrayList<Stone>
stones
The stones of the level
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
allStonesBroken()
checks whether all stones are brokenboolean
ballWasStarted()
Returns if the ball is moving or stoppedBall
getBall()
The getter for the ball objectPaddle
getPaddleBottom()
The getter for the bottom paddle objectPaddle
getPaddleTop()
The getter for the top paddle objectjava.util.ArrayList<Stone>
getStones()
The getter for the levels stonesprivate void
loadLevelData(int levelnr)
Loads the information for the level from a json-file located in the folder /res of the projectvoid
run()
The method of the level threadvoid
setFinished(boolean finished)
The setter for the levels game statevoid
startBall()
Sets ballWasStarted to true, the ball is movingvoid
stopBall()
Sets ballWasStarted to false, the ball is stoppedprivate void
updateStonesAndScore()
The updater for the levels stones and the player score-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
game
private Game game
The game to which the level belongs
-
levelnr
private int levelnr
The number of the level
-
score
private int score
The score of the level
-
ball
private Ball ball
The ball of the level
-
ballWasStarted
private boolean ballWasStarted
Flag that shows if the ball was started
-
levelFinished
private boolean levelFinished
Flag that shows if the level was finished
-
paddleTop
private Paddle paddleTop
The paddles of the level
-
paddleBottom
private Paddle paddleBottom
The paddles of the level
-
stones
private java.util.ArrayList<Stone> stones
The stones of the level
-
lifeCounter
private int lifeCounter
The life counter of the level
-
-
Constructor Detail
-
Level
public Level(Game game, int levelnr, int score)
The constructor creates a new level object and needs the current game object, the number of the level to be created and the current score- Parameters:
game
- The game objectlevelnr
- The number of the new level objectscore
- The score
-
-
Method Detail
-
getBall
public Ball getBall()
The getter for the ball object
-
startBall
public void startBall()
Sets ballWasStarted to true, the ball is moving
-
stopBall
public void stopBall()
Sets ballWasStarted to false, the ball is stopped
-
ballWasStarted
public boolean ballWasStarted()
Returns if the ball is moving or stopped- Returns:
- ballWasStarted True: the ball is moving; false: the ball is stopped
-
run
public void run()
The method of the level thread- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
loadLevelData
private void loadLevelData(int levelnr)
Loads the information for the level from a json-file located in the folder /res of the project- Parameters:
levelnr
- The number X for the LevelX.json file
-
getPaddleTop
public Paddle getPaddleTop()
The getter for the top paddle object- Specified by:
getPaddleTop
in interfaceILevel
- Returns:
- paddleTop The top paddle of the level
-
getPaddleBottom
public Paddle getPaddleBottom()
The getter for the bottom paddle object- Specified by:
getPaddleBottom
in interfaceILevel
- Returns:
- paddleBottom The bottom paddle of the level
-
setFinished
public void setFinished(boolean finished)
The setter for the levels game state- Specified by:
setFinished
in interfaceILevel
- Parameters:
finished
- game state
-
getStones
public java.util.ArrayList<Stone> getStones()
The getter for the levels stones
-
updateStonesAndScore
private void updateStonesAndScore()
The updater for the levels stones and the player score
-
allStonesBroken
private boolean allStonesBroken()
checks whether all stones are broken- Returns:
- true when all stones are broken
-
-