Documentation ¶
Overview ¶
This is a simple implementation of a console-based Tetris clone. It only works where termbox-go works (linux/mac should be fine).
Index ¶
- type Board
- type ColorMap
- type Direction
- type Game
- func (game *Game) DrawDynamic(clearOnly bool)
- func (game *Game) DrawGameOver()
- func (game *Game) DrawPauseScreen()
- func (game *Game) GeneratePiece() *Piece
- func (game *Game) Move(where Direction)
- func (game *Game) PauseToggle()
- func (game *Game) QuickDrop()
- func (game *Game) Rotate()
- func (game *Game) Start()
- type GameEvent
- type Piece
- type PieceInstance
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Board ¶
type Board struct {
// contains filtered or unexported fields
}
A Board represents the state of a tetris game board, including the current piece that is descending and the blocks which already exist on the board.
type ColorMap ¶
type ColorMap map[Vector]termbox.Attribute
A map from a point on a board to the color of that cell.
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
A Game tracks the entire game state of tetris, including the Board, the upcoming piece, the game speed (dropDelayMillis), the score, and various other internal data.
func (*Game) DrawDynamic ¶
Draw the dynamic parts of the game interface (the board, the next piece preview pane, and the score). The static parts should be drawn with the drawStaticBoardParts() function, if needed. If clearOnly is true, the board and preview pane will be cleared rather than redrawn.
func (*Game) DrawGameOver ¶
func (game *Game) DrawGameOver()
Draw the "GAME OVER" overlay on top of the game interface.
func (*Game) DrawPauseScreen ¶
func (game *Game) DrawPauseScreen()
Draw the pause screen, hiding the game board and next piece.
func (*Game) GeneratePiece ¶
Randomly choose a new game piece from among the the available pieces.
func (*Game) PauseToggle ¶
func (game *Game) PauseToggle()
Pause or unpause the game, depending on game.paused.