Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/cespare/go-tetris
/ functions
Functions
39 in github.com/cespare/go-tetris
⨍
Functions
39
◇
Types & classes
8
↓ 23 callers
Function
printBorderCharacter
Print a box-drawing border character.
tetris/drawing.go:68
↓ 7 callers
Method
plus
Add two vectors.
tetris/vector.go:9
↓ 5 callers
Method
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 drawS
tetris/game.go:291
↓ 4 callers
Function
drawStaticBoardParts
* // See http://en.wikipedia.org/wiki/Box-drawing_character for unicode characters. */
tetris/drawing.go:94
↓ 4 callers
Function
printString
Print a message in white text.
tetris/drawing.go:54
↓ 4 callers
Function
setBoardCell
A board cell is two terminal cells wide, for squaritude. Only need to set the whole bg color (for filling in a cell).
tetris/drawing.go:48
↓ 4 callers
Function
setCell
Our own wrapper around termbox.SetCell which knows the background color we're using.
tetris/drawing.go:42
↓ 3 callers
Method
GeneratePiece
Randomly choose a new game piece from among the the available pieces.
tetris/game.go:197
↓ 3 callers
Method
Move
Attempt to move.
tetris/game.go:252
↓ 3 callers
Method
currentPieceInCollision
Finds whether the current piece is in collision (going over the edge, or overlapping existing occupied blocks). This is useful for testing for collisi
tetris/board.go:34
↓ 3 callers
Method
instance
Find the current PieceInstance of this piece.
tetris/piece.go:20
↓ 3 callers
Method
startTicker
Start up the ticker with the appropriate interval based on the current score.
tetris/game.go:50
↓ 2 callers
Method
DrawPauseScreen
Draw the pause screen, hiding the game board and next piece.
tetris/game.go:352
↓ 2 callers
Method
PauseToggle
Pause or unpause the game, depending on game.paused.
tetris/game.go:339
↓ 2 callers
Method
anchor
Anchor the current piece to the board, clears lines, increments the score, and generate a new piece. Sets the 'game over' state if the new piece overl
tetris/game.go:203
↓ 2 callers
Method
contains
Returns whether a vector is a member of the color map.
tetris/board.go:11
↓ 2 callers
Method
moveIfPossible
Moves the current piece to another location, if possible. The current piece is updated if this is successful; otherwise, the piece is left unmoved. Th
tetris/board.go:49
↓ 2 callers
Method
rowComplete
Check whether a horizontal row is complete.
tetris/board.go:68
↓ 2 callers
Method
stopTicker
Stop the game ticker. This stops automatic advancement of the piece.
tetris/game.go:60
↓ 2 callers
Function
waitForUserEvent
A blocking function that waits for user input and then emits the appropriate GameEvent.
tetris/game.go:151
↓ 1 callers
Method
CellColor
Finds the color of a particular board cell. It returns the background color if the cell is empty.
tetris/board.go:119
↓ 1 callers
Method
DrawGameOver
Draw the "GAME OVER" overlay on top of the game interface.
tetris/game.go:371
↓ 1 callers
Function
NewGame
Initialize a new game, ready to be started with Start().
tetris/game.go:35
↓ 1 callers
Method
QuickDrop
Drop the piece all the way and anchor it.
tetris/game.go:272
↓ 1 callers
Method
Rotate
Rotates the current game piece, if possible.
tetris/game.go:281
↓ 1 callers
Method
Start
Start running the game. It will continue indefinitely until the user exits.
tetris/game.go:80
↓ 1 callers
Method
clearRows
Clear any complete rows and move the above blocks down. Returns the number of cleared rows.
tetris/board.go:95
↓ 1 callers
Method
clearedRows
Find all completed rows.
tetris/board.go:108
↓ 1 callers
Method
collapseRow
Clear a single row and move every above cell down.
tetris/board.go:78
↓ 1 callers
Function
drawDigitAsAscii
Print the current score in big ascii art digits
tetris/drawing.go:85
↓ 1 callers
Method
equals
Determine whether two vectors are the same.
tetris/vector.go:14
↓ 1 callers
Method
mergeCurrentPiece
Merge the blocks of the current piece into the game board and remove the current piece.
tetris/board.go:60
↓ 1 callers
Function
newBoard
Create a new empty tetris board with no current piece.
tetris/board.go:25
↓ 1 callers
Function
printStringVertical
Print a message vertically in white text.
tetris/drawing.go:61
↓ 1 callers
Method
rotate
Go to the next rotation.
tetris/piece.go:25
↓ 1 callers
Function
tetrisPieces
This has all the hard-coded tetris pieces. TODO: It might be nice to have a way to parse these from a configuration file. Maybe the format could look
tetris/piece.go:49
↓ 1 callers
Method
unrotate
Go to the previous rotation.
tetris/piece.go:30
Function
main
()
go-tetris.go:11
Function
waitForTick
A blocking function that waits on a ticker and then emits a MoveDown event.
tetris/game.go:145