Documentation ¶
Index ¶
- type Game
- func (g *Game) EndGame()
- func (g *Game) GetBagTetriminos() []tetris.Tetrimino
- func (g *Game) GetDefaultFallInterval() time.Duration
- func (g *Game) GetHoldTetrimino() *tetris.Tetrimino
- func (g *Game) GetLevel() int
- func (g *Game) GetLinesCleared() int
- func (g *Game) GetTotalScore() int
- func (g *Game) GetVisibleMatrix() (tetris.Matrix, error)
- func (g *Game) HardDrop() (bool, error)
- func (g *Game) Hold() (bool, error)
- func (g *Game) IsGameOver() bool
- func (g *Game) MoveLeft()
- func (g *Game) MoveRight()
- func (g *Game) Rotate(clockwise bool) error
- func (g *Game) TickLower() (bool, error)
- func (g *Game) ToggleSoftDrop() time.Duration
- type Input
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game represents a single player game of Tetris. This can be used for Marathon, Sprint, Ultra and other single player modes.
func (*Game) GetBagTetriminos ¶
func (*Game) GetDefaultFallInterval ¶
func (*Game) GetHoldTetrimino ¶
func (*Game) GetLinesCleared ¶
func (*Game) GetTotalScore ¶
func (*Game) Hold ¶
Hold will swap the current Tetrimino with the hold Tetrimino. If the hold Tetrimino is empty, the current Tetrimino is placed in the hold slot and the setupNewTetInPlay Tetrimino is drawn. If not allowed to hold, no action is taken. If true is returned the game is over.
func (*Game) IsGameOver ¶
func (*Game) TickLower ¶
TickLower moves the current Tetrimino down one row. This should be triggered at a regular interval calculated using Fall. If the Tetrimino cannot move down, it is locked in place and true is returned. Game Over is updated if needed.
func (*Game) ToggleSoftDrop ¶
ToggleSoftDrop toggles the Soft Drop state of the game. If Soft Drop is enabled, the game will calculate the number of lines cleared and add them to the score. The time interval for the Fall system is returned.
type Input ¶
type Input struct { Level int // The starting level of the game. MaxLevel int // The maximum level the game can reach. 0 means no limit. IncreaseLevel bool // Whether the level should increase as the game progresses. EndOnMaxLevel bool // Whether the game should end when the maximum level is reached. MaxLines int // The maximum number of lines to clear before the game ends. 0 means no limit. EndOnMaxLines bool // Whether the game should end when the maximum number of lines is cleared. GhostEnabled bool // Whether the ghost Tetrimino should be displayed. }