Package tetris.gui
Class GUI
java.lang.Object
tetris.gui.GUI
The class GUI implements the graphical user interface of the Tetris game.
- Version:
- 2.1
- Author:
- Stephan Fischli
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the graphical user interface.voidDraws a single block.voiddrawBlocks(Collection<Block> blocks) Draws a collection of blocks.voiddrawBlocks(Block[] blocks) Draws an array of blocks.voidsetActionHandler(ActionHandler handler) Registers the handler of the figure action events.voidsetHighScore(int highScore) Sets the high score of the game to be displayed.voidsetLevel(int level) Sets the level of the game to be displayed.voidsetScore(int score) Sets the score of the game to be displayed.voidSets the status of the game to be displayed.voidsetStatusHandler(StatusHandler handler) Registers the handler of the status change events.Waits for an action event.
-
Constructor Details
-
GUI
public GUI(int width, int height) Constructs a graphical user interface.- Parameters:
width- the width of the fieldheight- the height of the field
-
GUI
public GUI(int width, int height, int scaleFactor) Constructs a graphical user interface.- Parameters:
width- the width of the fieldheight- the height of the fieldscaleFactor- the scale factor
-
-
Method Details
-
setActionHandler
Registers the handler of the figure action events.- Parameters:
handler- the action handler
-
setStatusHandler
Registers the handler of the status change events.- Parameters:
handler- the status handler
-
waitEvent
Waits for an action event.- Returns:
- the event that has arrived.
-
drawBlock
Draws a single block.- Parameters:
block- the block to be drawn
-
drawBlocks
Draws an array of blocks.- Parameters:
blocks- the blocks to be drawn
-
drawBlocks
Draws a collection of blocks.- Parameters:
blocks- the blocks to be drawn
-
setLevel
public void setLevel(int level) Sets the level of the game to be displayed.- Parameters:
level- the level to be set
-
setScore
public void setScore(int score) Sets the score of the game to be displayed.- Parameters:
score- the score to be set
-
setHighScore
public void setHighScore(int highScore) Sets the high score of the game to be displayed.- Parameters:
highScore- the high score to be set
-
setStatus
Sets the status of the game to be displayed.- Parameters:
status- the status to be set
-
clear
public void clear()Clears the graphical user interface.
-