Package tetris.model
Class Game
java.lang.Object
tetris.model.Game
The class Game implements the Tetris game.
- Version:
- 2.1
- Author:
- Stephan Fischli
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
The class FigureController is used to control the figure of the Tetris game. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Field
private Figure
The figure of the game.private Game.FigureController
The figure controller.private final GUI
The graphical user interface.private final Scoring
The scoring of the game. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Creates a random figure at the top of the field and stops the game, if it collides with the field.private void
Adds the current figure to the field, removes the full rows, updates the score and creates a new figure.void
start()
Starts the game by creating a figure, registering an action handler and starting the figure controller.void
stop()
Stops the game by stopping the figure controller and unregistering the action handler.private void
Updates the graphical user interface according to the current state of the game.
-
Field Details
-
gui
The graphical user interface. -
field
-
scoring
The scoring of the game. -
figure
The figure of the game. -
figureController
The figure controller.
-
-
Constructor Details
-
Game
Constructs a game with the specified graphical user interface.- Parameters:
gui
- the graphical user interface
-
-
Method Details
-
start
public void start()Starts the game by creating a figure, registering an action handler and starting the figure controller. -
stop
public void stop()Stops the game by stopping the figure controller and unregistering the action handler. -
createFigure
private void createFigure()Creates a random figure at the top of the field and stops the game, if it collides with the field. -
figureLanded
private void figureLanded()Adds the current figure to the field, removes the full rows, updates the score and creates a new figure. -
updateGUI
private void updateGUI()Updates the graphical user interface according to the current state of the game.
-