Documentation ¶
Index ¶
- Constants
- Variables
- type Angle
- type BlockType
- type Field
- func (f *Field) AbsorbPiece(piece *Piece, x, y int, angle Angle)
- func (f *Field) Draw(r *ebiten.Image, x, y int)
- func (f *Field) DropPiece(piece *Piece, x, y int, angle Angle) int
- func (f *Field) IsBlocked(x, y int) bool
- func (f *Field) IsFlushAnimating() bool
- func (f *Field) MovePieceToLeft(piece *Piece, x, y int, angle Angle) int
- func (f *Field) MovePieceToRight(piece *Piece, x, y int, angle Angle) int
- func (f *Field) PieceDroppable(piece *Piece, x, y int, angle Angle) bool
- func (f *Field) RotatePieceLeft(piece *Piece, x, y int, angle Angle) Angle
- func (f *Field) RotatePieceRight(piece *Piece, x, y int, angle Angle) Angle
- func (f *Field) SetEndFlushAnimating(fn func(lines int))
- func (f *Field) Update()
- type Game
- type GameScene
- type GameState
- type GamepadScene
- type Input
- type Piece
- type Scene
- type SceneManager
- type TitleScene
Constants ¶
const ( ScreenWidth = 256 ScreenHeight = 240 )
Variables ¶
var Pieces map[BlockType]*Piece
Pieces is the set of all the possible pieces.
Functions ¶
This section is empty.
Types ¶
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 ¶
AbsorbPiece absorbs the piece at (x, y) with the given angle into the field.
func (*Field) DropPiece ¶
DropPiece tries to drop the piece to the right and returns the piece's next y position.
func (*Field) IsBlocked ¶
IsBlocked returns a boolean value indicating whether there is a block at position (x, y) on the field.
func (*Field) IsFlushAnimating ¶ added in v1.7.0
IsFlushAnimating returns a boolean value indicating whether there is a flush animation.
func (*Field) MovePieceToLeft ¶
MovePieceToLeft tries to move the piece to the left and returns the piece's next x position.
func (*Field) MovePieceToRight ¶
MovePieceToRight tries to move the piece to the right and returns the piece's next x position.
func (*Field) PieceDroppable ¶
PieceDroppable returns a boolean value indicating whether the piece at (x, y) with the given angle can drop.
func (*Field) RotatePieceLeft ¶
RotatePieceLeft tries to rotate the piece to the left and returns the piece's next angle.
func (*Field) RotatePieceRight ¶
RotatePieceRight tries to rotate the piece to the right and returns the piece's next angle.
func (*Field) SetEndFlushAnimating ¶ added in v1.7.0
SetEndFlushAnimating sets a callback fired on the end of flush animation. The callback argument is the number of flushed lines.
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
type GameScene ¶
type GameScene struct {
// contains filtered or unexported fields
}
func NewGameScene ¶
func NewGameScene() *GameScene
type GameState ¶
type GameState struct { SceneManager *SceneManager Input *Input }
type GamepadScene ¶
type GamepadScene struct {
// contains filtered or unexported fields
}
func (*GamepadScene) Draw ¶
func (s *GamepadScene) Draw(screen *ebiten.Image)
func (*GamepadScene) Update ¶
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 (*Input) GamepadIDButtonPressed ¶ added in v1.8.0
GamepadIDButtonPressed returns a gamepad ID where at least one button is pressed. If no button is pressed, GamepadIDButtonPressed returns -1.
func (*Input) IsRotateLeftJustPressed ¶ added in v1.7.0
func (*Input) IsRotateRightJustPressed ¶ added in v1.7.0
func (*Input) StateForDown ¶
func (*Input) StateForLeft ¶
func (*Input) StateForRight ¶
type Piece ¶
type Piece struct {
// contains filtered or unexported fields
}
func (*Piece) DrawAtCenter ¶
func (*Piece) InitialPosition ¶
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