Package break_out.model
Class Level
- java.lang.Object
-
- java.lang.Thread
-
- break_out.model.Level
-
- All Implemented Interfaces:
java.lang.Runnable
public class Level extends java.lang.Thread
This class contains information about the running game- Author:
- dmlux, I. Schumacher, modified by 175
-
-
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 int
levelnr
The number of the levelprivate int
score
The score of the level
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
ballWasStarted()
Returns if the ball is moving or stoppedBall
getBall()
The getter for the ball objectprivate 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
startBall()
Sets ballWasStarted to true, the ball is movingvoid
stopBall()
Sets ballWasStarted to false, the ball is stopped-
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
-
-
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- Returns:
- ball The ball of the level
-
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
-
-