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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears the graphical user interface.void
Draws a single block.void
drawBlocks
(Collection<Block> blocks) Draws a collection of blocks.void
drawBlocks
(Block[] blocks) Draws an array of blocks.void
setActionHandler
(ActionHandler handler) Registers the handler of the figure action events.void
setHighScore
(int highScore) Sets the high score of the game to be displayed.void
setLevel
(int level) Sets the level of the game to be displayed.void
setScore
(int score) Sets the score of the game to be displayed.void
Sets the status of the game to be displayed.void
setStatusHandler
(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.
-