## Documentation ¶

### Constants ¶

View Source
```const (
ScreenWidth  = 256
ScreenHeight = 240
)```

### Variables ¶

View Source
`var Pieces map[BlockType]*Piece`

Pieces is the set of all the possible pieces.

### Functions ¶

This section is empty.

### Types ¶

#### type Angle ¶

`type Angle int`
```const (
Angle0 Angle = iota
Angle90
Angle180
Angle270
)```

#### func (Angle) RotateLeft ¶

`func (a Angle) RotateLeft() Angle`

#### func (Angle) RotateRight ¶

`func (a Angle) RotateRight() Angle`

#### type BlockType ¶

`type BlockType int`
```const (
BlockTypeNone BlockType = iota
BlockType1
BlockType2
BlockType3
BlockType4
BlockType5
BlockType6
BlockType7
BlockTypeMax = BlockType7
)```

#### type Field ¶

```type Field struct {
// contains filtered or unexported fields
}```

Field represents a game field with block states.

#### func (*Field) AbsorbPiece ¶

`func (f *Field) AbsorbPiece(piece *Piece, x, y int, angle Angle)`

AbsorbPiece absorbs the piece at (x, y) with the given angle into the field.

#### func (*Field) Draw ¶

`func (f *Field) Draw(r *ebiten.Image, x, y int)`

#### func (*Field) DropPiece ¶

`func (f *Field) DropPiece(piece *Piece, x, y int, angle Angle) int`

DropPiece tries to drop the piece to the right and returns the piece's next y position.

#### func (*Field) IsBlocked ¶

`func (f *Field) IsBlocked(x, y int) bool`

IsBlocked returns a boolean value indicating whether there is a block at position (x, y) on the field.

#### func (*Field) IsFlushAnimating ¶

`func (f *Field) IsFlushAnimating() bool`

IsFlushAnimating returns a boolean value indicating whether there is a flush animation.

#### func (*Field) MovePieceToLeft ¶

`func (f *Field) MovePieceToLeft(piece *Piece, x, y int, angle Angle) int`

MovePieceToLeft tries to move the piece to the left and returns the piece's next x position.

#### func (*Field) MovePieceToRight ¶

`func (f *Field) MovePieceToRight(piece *Piece, x, y int, angle Angle) int`

MovePieceToRight tries to move the piece to the right and returns the piece's next x position.

#### func (*Field) PieceDroppable ¶

`func (f *Field) PieceDroppable(piece *Piece, x, y int, angle Angle) bool`

PieceDroppable returns a boolean value indicating whether the piece at (x, y) with the given angle can drop.

#### func (*Field) RotatePieceLeft ¶

`func (f *Field) RotatePieceLeft(piece *Piece, x, y int, angle Angle) Angle`

RotatePieceLeft tries to rotate the piece to the left and returns the piece's next angle.

#### func (*Field) RotatePieceRight ¶

`func (f *Field) RotatePieceRight(piece *Piece, x, y int, angle Angle) Angle`

RotatePieceRight tries to rotate the piece to the right and returns the piece's next angle.

#### func (*Field) SetEndFlushAnimating ¶

`func (f *Field) SetEndFlushAnimating(fn func(lines int))`

SetEndFlushAnimating sets a callback fired on the end of flush animation. The callback argument is the number of flushed lines.

#### func (*Field) Update ¶

`func (f *Field) Update()`

#### type Game ¶

```type Game struct {
// contains filtered or unexported fields
}```

#### func (*Game) Draw ¶

`func (g *Game) Draw(screen *ebiten.Image)`

#### func (*Game) Layout ¶

`func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)`

#### func (*Game) Update ¶

`func (g *Game) Update() error`

#### type GameScene ¶

```type GameScene struct {
// contains filtered or unexported fields
}```

#### func NewGameScene ¶

`func NewGameScene() *GameScene`

#### func (*GameScene) Draw ¶

`func (s *GameScene) Draw(r *ebiten.Image)`

#### func (*GameScene) Update ¶

`func (s *GameScene) Update(state *GameState) error`

#### type GameState ¶

```type GameState struct {
SceneManager *SceneManager
Input        *Input
}```

```type GamepadScene struct {
// contains filtered or unexported fields
}```

`func (s *GamepadScene) Draw(screen *ebiten.Image)`

`func (s *GamepadScene) Update(state *GameState) error`

#### type Input ¶

```type Input struct {
// contains filtered or unexported fields
}```

Input manages the input state including gamepads and keyboards.

`func (i *Input) GamepadIDButtonPressed() ebiten.GamepadID`

GamepadIDButtonPressed returns a gamepad ID where at least one button is pressed. If no button is pressed, GamepadIDButtonPressed returns -1.

#### func (*Input) IsRotateLeftJustPressed ¶

`func (i *Input) IsRotateLeftJustPressed() bool`

#### func (*Input) IsRotateRightJustPressed ¶

`func (i *Input) IsRotateRightJustPressed() bool`

#### func (*Input) StateForDown ¶

`func (i *Input) StateForDown() int`

#### func (*Input) StateForLeft ¶

`func (i *Input) StateForLeft() int`

#### func (*Input) StateForRight ¶

`func (i *Input) StateForRight() int`

#### func (*Input) Update ¶

`func (i *Input) Update()`

#### type Piece ¶

```type Piece struct {
// contains filtered or unexported fields
}```

#### func (*Piece) AbsorbInto ¶

`func (p *Piece) AbsorbInto(field *Field, x, y int, angle Angle)`

#### func (*Piece) Draw ¶

`func (p *Piece) Draw(r *ebiten.Image, x, y int, angle Angle)`

#### func (*Piece) DrawAtCenter ¶

`func (p *Piece) DrawAtCenter(r *ebiten.Image, x, y, width, height int, angle Angle)`

#### func (*Piece) InitialPosition ¶

`func (p *Piece) InitialPosition() (int, int)`

#### type Scene ¶

```type Scene interface {
Update(state *GameState) error
Draw(screen *ebiten.Image)
}```

#### type SceneManager ¶

```type SceneManager struct {
// contains filtered or unexported fields
}```

#### func (*SceneManager) Draw ¶

`func (s *SceneManager) Draw(r *ebiten.Image)`

#### func (*SceneManager) GoTo ¶

`func (s *SceneManager) GoTo(scene Scene)`

#### func (*SceneManager) Update ¶

`func (s *SceneManager) Update(input *Input) error`

#### type TitleScene ¶

```type TitleScene struct {
// contains filtered or unexported fields
}```

#### func (*TitleScene) Draw ¶

`func (s *TitleScene) Draw(r *ebiten.Image)`

#### func (*TitleScene) Update ¶

`func (s *TitleScene) Update(state *GameState) error`