ebiten: github.com/hajimehoshi/ebiten/examples/2048/2048 Index | Files

package twenty48

import "github.com/hajimehoshi/ebiten/examples/2048/2048"

Index

Package Files

board.go colors.go game.go input.go tile.go

Constants

const (
    ScreenWidth  = 420
    ScreenHeight = 600
)

func MoveTiles Uses

func MoveTiles(tiles map[*Tile]struct{}, size int, dir Dir) bool

MoveTiles moves tiles in the given tiles map if possible. MoveTiles returns true if there are tiles that are to move, otherwise false.

When MoveTiles is called, all tiles must not be about to move.

type Board Uses

type Board struct {
    // contains filtered or unexported fields
}

Board represents the game board.

func NewBoard Uses

func NewBoard(size int) (*Board, error)

NewBoard generates a new Board with giving a size.

func (*Board) Draw Uses

func (b *Board) Draw(boardImage *ebiten.Image)

Draw draws the board to the given boardImage.

func (*Board) Move Uses

func (b *Board) Move(dir Dir) error

Move enqueues tile moving tasks.

func (*Board) Size Uses

func (b *Board) Size() (int, int)

Size returns the board size.

func (*Board) Update Uses

func (b *Board) Update(input *Input) error

Update updates the board state.

type Dir Uses

type Dir int

Dir represents a direction.

const (
    DirUp Dir = iota
    DirRight
    DirDown
    DirLeft
)

func (Dir) String Uses

func (d Dir) String() string

String returns a string representing the direction.

func (Dir) Vector Uses

func (d Dir) Vector() (x, y int)

Vector returns a [-1, 1] value for each axis.

type Game Uses

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

Game represents a game state.

func NewGame Uses

func NewGame() (*Game, error)

NewGame generates a new Game object.

func (*Game) Draw Uses

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

Draw draws the current game to the given screen.

func (*Game) Update Uses

func (g *Game) Update() error

Update updates the current game state.

type Input Uses

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

Input represents the current key states.

func NewInput Uses

func NewInput() *Input

NewInput generates a new Input object.

func (*Input) Dir Uses

func (i *Input) Dir() (Dir, bool)

Dir returns a currently pressed direction. Dir returns false if no direction key is pressed.

func (*Input) Update Uses

func (i *Input) Update()

Update updates the current input states.

type Tile Uses

type Tile struct {
    // contains filtered or unexported fields
}

Tile represents a tile information including TileData and animation states.

func NewTile Uses

func NewTile(value int, x, y int) *Tile

NewTile creates a new Tile object.

func (*Tile) Draw Uses

func (t *Tile) Draw(boardImage *ebiten.Image)

Draw draws the current tile to the given boardImage.

func (*Tile) IsMoving Uses

func (t *Tile) IsMoving() bool

IsMoving returns a boolean value indicating if the tile is animating.

func (*Tile) NextPos Uses

func (t *Tile) NextPos() (int, int)

NextPos returns the tile's next position. NextPos is used only at testing so far.

func (*Tile) NextValue Uses

func (t *Tile) NextValue() int

NextValue returns the tile's current value. NextValue is used only at testing so far.

func (*Tile) Pos Uses

func (t *Tile) Pos() (int, int)

Pos returns the tile's current position. Pos is used only at testing so far.

func (*Tile) Update Uses

func (t *Tile) Update() error

Update updates the tile's animation states.

func (*Tile) Value Uses

func (t *Tile) Value() int

Value returns the tile's current value. Value is used only at testing so far.

type TileData Uses

type TileData struct {
    // contains filtered or unexported fields
}

TileData represents a tile information like a value and a position.

Package twenty48 imports 13 packages (graph). Updated 2019-03-14. Refresh now. Tools for package owners.