Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( EmptyPiece = Piece{} IPiece = Piece{0x0F00, 0x4444, 0x00F0, 0x2222} JPiece = Piece{0x1700, 0x6220, 0x0740, 0x2230} LPiece = Piece{0x4700, 0x2260, 0x0710, 0x3220} OPiece = Piece{0x6600, 0x6600, 0x6600, 0x6600} SPiece = Piece{0x6300, 0x2640, 0x0630, 0x1320} TPiece = Piece{0x2700, 0x2620, 0x0720, 0x2320} ZPiece = Piece{0x3600, 0x4620, 0x0360, 0x2310} )
A table that represents each piece from https://tetris.fandom.com/wiki/SRS in binary starting with 1 top left going per row, here in hexadecimal shorthand.
var K3CW = Kicks{
0: {{X: 0, Y: 0}, {X: -1, Y: 0}, {X: -1, Y: -1}, {X: 0, Y: 2}, {X: -1, Y: 2}},
1: {{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 1, Y: 1}, {X: 0, Y: -2}, {X: 1, Y: -2}},
2: {{X: 0, Y: 0}, {X: 1, Y: 0}, {X: 1, Y: -1}, {X: 0, Y: 2}, {X: 1, Y: 2}},
3: {{X: 0, Y: 0}, {X: -1, Y: 0}, {X: -1, Y: 1}, {X: 0, Y: -2}, {X: -1, Y: -2}},
}
Kics for all pieces except I and O pieces
var LCW = Kicks{
0: {{X: 0, Y: 0}, {X: -2, Y: 0}, {X: 1, Y: 0}, {X: -2, Y: 1}, {X: 1, Y: -2}},
1: {{X: 0, Y: 0}, {X: -1, Y: 0}, {X: 2, Y: 0}, {X: -1, Y: -2}, {X: 2, Y: 1}},
2: {{X: 0, Y: 0}, {X: 2, Y: 0}, {X: -1, Y: 0}, {X: 2, Y: -1}, {X: -1, Y: 2}},
3: {{X: 0, Y: 0}, {X: 1, Y: 0}, {X: -2, Y: 0}, {X: 1, Y: 2}, {X: -2, Y: -1}},
}
Long Bar (I piece) Kicks
var LockDelay = time.Second / 2
var Swapped bool
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field [][]int
var HoldBox Field
type Kicks ¶ added in v0.1.0
As at the bottom of https://tetris.fandom.com/wiki/SRS but Y inverse because we start Y at the top
type Placement ¶ added in v0.0.2
type Placement struct { X int Y int Rot Rotation Lock time.Time // contains filtered or unexported fields }
a placement is the combination of a piece and where it exactly is on the board we use this both for the actual piece and for checking hypothetical positions
func (Placement) Collide ¶ added in v0.0.2
Collide checks if any squares of the Placement and the Field overlap
func (Placement) Field ¶ added in v0.0.2
Field translates the Placement into a Field format When it gets out of the board, we return that to the caller with a bool