game2048

package module
v0.0.0-...-4c55bb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game2048

type Game2048 struct {
	Matrix [][]int
	Size   int
	Moves  int
	Score  int
}

Game2048 the main struct for the library

func NewGame2048

func NewGame2048(size int) *Game2048

NewGame2048 is the constructor of the Game2048, returns a pointer to Game2048 instance

func (*Game2048) AddRandom

func (g *Game2048) AddRandom()

AddRandom adds a 2 or 4 on a space in the matrix randomly

func (*Game2048) GenerateImage

func (g *Game2048) GenerateImage(name string, srcDir string)

GenerateImage generates a image of the actual state

func (*Game2048) MoveDOWN

func (g *Game2048) MoveDOWN()

MoveDOWN moves down all possible cells

func (*Game2048) MoveLEFT

func (g *Game2048) MoveLEFT()

MoveLEFT moves left all possible cells

func (*Game2048) MoveRIGHT

func (g *Game2048) MoveRIGHT()

MoveRIGHT moves right all possible cells

func (*Game2048) MoveUP

func (g *Game2048) MoveUP()

MoveUP moves up all possible cells

func (*Game2048) Print

func (g *Game2048) Print()

Print prints well formated data of the game

func (*Game2048) ValidateDOWN

func (g *Game2048) ValidateDOWN() bool

ValidateDOWN checks if can move down

func (*Game2048) ValidateLEFT

func (g *Game2048) ValidateLEFT() bool

ValidateLEFT checks if can move left

func (*Game2048) ValidateRIGHT

func (g *Game2048) ValidateRIGHT() bool

ValidateRIGHT checks if can move right

func (*Game2048) ValidateUP

func (g *Game2048) ValidateUP() bool

ValidateUP checks if can move up

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL