Package sac.model
Class Model
java.lang.Object
sac.model.Model
The model for a Tetris Game.
This class acts as a wrapper for Board with extra functionality.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCalculate the ghost piece of current piece.Get the current piece being held.Get the upcoming pieces.boolean
isGameOn()
Check if the game is on.void
modelTick
(Model.MoveType moveType) Update the model by moveTypevoid
newGame()
Clear the current game and create a new one.void
setGameMode
(GameMode gameMode) Set the game mode.void
Start the game.
-
Field Details
-
board
-
-
Constructor Details
-
Model
public Model()Initialize a new model.
-
-
Method Details
-
setGameMode
Set the game mode.Note: GameMode stores the actual game logic.
- Parameters:
gameMode
- The desired GameMode.
-
newGame
public void newGame()Clear the current game and create a new one. -
startGame
public void startGame()Start the game. -
modelTick
Update the model by moveType- Parameters:
moveType
- The movement.
-
isGameOn
public boolean isGameOn()Check if the game is on.- Returns:
- If the game is on.
-
getGhostPiecePositions
Calculate the ghost piece of current piece.- Returns:
- A list of point representing the body of the ghost piece.
-
getHoldPiece
Get the current piece being held.- Returns:
- The piece being held.
-
getPreview
Get the upcoming pieces.- Returns:
- A list of upcoming pieces.
-