Documentation ¶
Overview ¶
Modified and adapted from github.com/MichaelS11/go-tetris.git Under MIT.
Index ¶
- func ChangeBoardSize(width int, height int)
- func NewBoard()
- func NewEngine()
- func NewMinos()
- func NewView()
- func Start() error
- func ValidDisplayLocation(x int, y int) bool
- type Board
- func (board *Board) Clear()
- func (board *Board) DrawBoard()
- func (board *Board) DrawCurrentMino()
- func (board *Board) DrawCursor(x int, y int)
- func (board *Board) DrawDropMino()
- func (board *Board) DrawPreviewMino()
- func (board *Board) EmptyBoard()
- func (board *Board) MinoDrop()
- func (board *Board) MinoMoveDown()
- func (board *Board) MinoMoveLeft()
- func (board *Board) MinoMoveRight()
- func (board *Board) MinoRotateLeft()
- func (board *Board) MinoRotateRight()
- func (board *Board) NextBoard()
- func (board *Board) PreviousBoard()
- func (board *Board) RotateLeft(x int, y int)
- func (board *Board) RotateRight(x int, y int)
- func (board *Board) SetColor(x int, y int, color tcell.Color, rotation int)
- func (board *Board) StartLockDelayIfBottom() bool
- func (board *Board) ValidBlockLocation(x int, y int, mustBeOnBoard bool) bool
- type Boards
- type BoardsJSON
- type Engine
- func (engine *Engine) AddDeleteLines(lines int)
- func (engine *Engine) AddScore(add int)
- func (engine *Engine) GameOver()
- func (engine *Engine) LevelUp()
- func (engine *Engine) NewGame()
- func (engine *Engine) Pause()
- func (engine *Engine) PreviewBoard()
- func (engine *Engine) ProcessEventKey(eventKey *tcell.EventKey)
- func (engine *Engine) ResetTimer(duration time.Duration)
- func (engine *Engine) Run()
- func (engine *Engine) Start()
- func (engine *Engine) Stop()
- func (engine *Engine) UnPause()
- type EventEngineStopRun
- type EventGame
- type Mino
- func (mino *Mino) CloneMoveDown() *Mino
- func (mino *Mino) CloneMoveLeft() *Mino
- func (mino *Mino) CloneMoveRight() *Mino
- func (mino *Mino) CloneRotateLeft() *Mino
- func (mino *Mino) CloneRotateRight() *Mino
- func (mino *Mino) DrawMino(minoType MinoType)
- func (mino *Mino) MoveDown()
- func (mino *Mino) MoveLeft()
- func (mino *Mino) MoveRight()
- func (mino *Mino) MoveUp()
- func (mino *Mino) RotateLeft()
- func (mino *Mino) RotateRight()
- func (mino *Mino) SetOnBoard()
- func (mino *Mino) ValidLocation(mustBeOnBoard bool) bool
- type MinoBlocks
- type MinoRotation
- type MinoType
- type Minos
- type Ranking
- type Settings
- type View
- func (view *View) DrawBlock(x int, y int, color tcell.Color, rotation int)
- func (view *View) DrawCursor(x int, y int, color tcell.Color)
- func (view *View) DrawPreviewMinoBlock(x int, y int, color tcell.Color, rotation int, length int)
- func (view *View) RefreshScreen()
- func (view *View) ShowDeleteAnimation(lines []int)
- func (view *View) ShowGameOverAnimation()
- func (view *View) Stop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeBoardSize ¶
ChangeBoardSize changes board size
func ValidDisplayLocation ¶
ValidDisplayLocation checks if vaild display location
Types ¶
type Board ¶
type Board struct {
// contains filtered or unexported fields
}
Board is the Tetris board
func (*Board) DrawBoard ¶
func (board *Board) DrawBoard()
DrawBoard draws the board with help from view
func (*Board) DrawCurrentMino ¶
func (board *Board) DrawCurrentMino()
DrawCurrentMino draws the current mino
func (*Board) DrawCursor ¶
DrawCursor draws the edit cursor
func (*Board) DrawPreviewMino ¶
func (board *Board) DrawPreviewMino()
DrawPreviewMino draws the preview mino
func (*Board) EmptyBoard ¶
func (board *Board) EmptyBoard()
EmptyBoard removes all blocks/colors from the board
func (*Board) MinoRotateLeft ¶
func (board *Board) MinoRotateLeft()
MinoRotateLeft rotates mino right
func (*Board) MinoRotateRight ¶
func (board *Board) MinoRotateRight()
MinoRotateRight rotates mino right
func (*Board) PreviousBoard ¶
func (board *Board) PreviousBoard()
PreviousBoard switches to previous board
func (*Board) RotateLeft ¶
RotateLeft rotates cell left
func (*Board) RotateRight ¶
RotateRight rotates cell right
func (*Board) StartLockDelayIfBottom ¶
StartLockDelayIfBottom if at bottom, starts lock delay
type Boards ¶
type Boards struct {
// contains filtered or unexported fields
}
Boards holds all the boards
type BoardsJSON ¶
BoardsJSON is for JSON format of boards
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the Tetirs game engine
func (*Engine) AddDeleteLines ¶
AddDeleteLines adds deleted lines to score
func (*Engine) GameOver ¶
func (engine *Engine) GameOver()
GameOver pauses engine and sets to game over
func (*Engine) PreviewBoard ¶
func (engine *Engine) PreviewBoard()
PreviewBoard sets previewBoard to true
func (*Engine) ProcessEventKey ¶
ProcessEventKey process the key input event
func (*Engine) ResetTimer ¶
ResetTimer resets the time for lock delay or tick time
type EventEngineStopRun ¶
type EventEngineStopRun struct {
EventGame
}
EventEngineStopRun stop the run of the engine
type EventGame ¶
type EventGame struct {
// contains filtered or unexported fields
}
EventGame is an game event
type Mino ¶
type Mino struct {
// contains filtered or unexported fields
}
Mino is a mino
func (*Mino) CloneMoveDown ¶
CloneMoveDown creates copy of the mino and moves it down
func (*Mino) CloneMoveLeft ¶
CloneMoveLeft creates copy of the mino and moves it left
func (*Mino) CloneMoveRight ¶
CloneMoveRight creates copy of the mino and moves it right
func (*Mino) CloneRotateLeft ¶
CloneRotateLeft creates copy of the mino and rotates it left
func (*Mino) CloneRotateRight ¶
CloneRotateRight creates copy of the mino and rotates it right
func (*Mino) ValidLocation ¶
ValidLocation check if the mino is in a valid location
type Minos ¶
type Minos struct {
// contains filtered or unexported fields
}
Minos is a bag of minos
type Ranking ¶
type Ranking struct {
// contains filtered or unexported fields
}
Ranking holds the ranking scores
func (*Ranking) InsertScore ¶
InsertScore inserts a score into the rankings
type View ¶
type View struct { }
View is the display engine
func (*View) DrawCursor ¶
DrawCursor draws current cursor location
func (*View) DrawPreviewMinoBlock ¶
DrawPreviewMinoBlock draws the preview mino
func (*View) RefreshScreen ¶
func (view *View) RefreshScreen()
RefreshScreen refreshes the updated view to the screen
func (*View) ShowDeleteAnimation ¶
ShowDeleteAnimation draws the delete animation
func (*View) ShowGameOverAnimation ¶
func (view *View) ShowGameOverAnimation()
ShowGameOverAnimation draws one randomily picked gave over animation