Package tetris.model

Class Game

java.lang.Object
tetris.model.Game

public class Game extends Object
The class Game implements the Tetris game.
Version:
2.1
Author:
Stephan Fischli
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private class 
    The class FigureController is used to control the figure of the Tetris game.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Field
     
    private Figure
    The figure of the game.
    The figure controller.
    private final GUI
    The graphical user interface.
    private final Scoring
    The scoring of the game.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Game(GUI gui)
    Constructs a game with the specified graphical user interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    private 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
    Starts the game by creating a figure, registering an action handler and starting the figure controller.
    void
    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.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • gui

      private final GUI gui
      The graphical user interface.
    • field

      private final Field field
    • scoring

      private final Scoring scoring
      The scoring of the game.
    • figure

      private Figure figure
      The figure of the game.
    • figureController

      private Game.FigureController figureController
      The figure controller.
  • Constructor Details

    • Game

      public Game(GUI gui)
      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.