game

package
v0.0.0-...-a657feb Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Game

type Game struct {

	// Five position array of tetrominoes, where index
	//  0: Current dropping tetromino
	//  1: Coming up 1
	//  2: Coming up 2
	//  3: Coming up 3
	//  -- 4: On hold (TODO)
	Tetrominoes [5]Tetromino

	// Base offset of dropping tetromino
	// Can be outside of grid if current tetromino sprite has blank rows/columns
	Position      Vector
	GhostPosition Vector

	// Rotation of dropping tetromino
	// Should be >0 and <4
	Rotation int8

	Score uint64
	Level uint64
	Lines uint64

	// Internal stuff below
	Nickname string
	// contains filtered or unexported fields
}

Game --------------------------------------------------------------------------------------------

func NewGame

func NewGame(nickname string, dataChannel chan string) Game

func (*Game) AddScore

func (game *Game) AddScore(baseScore uint64, levelBoost bool)

func (*Game) Changed

func (game *Game) Changed()

func (*Game) Drop

func (game *Game) Drop()

func (*Game) GetGrid

func (game *Game) GetGrid() GameGrid

func (*Game) Iterate

func (game *Game) Iterate() bool

Game methods

func (*Game) Lockdown

func (game *Game) Lockdown() bool

func (*Game) MoveDown

func (game *Game) MoveDown() bool

func (*Game) MoveX

func (game *Game) MoveX(d int32) bool

func (*Game) NextTetromino

func (game *Game) NextTetromino()

func (*Game) Rotate

func (game *Game) Rotate(d int8)

func (*Game) SetKey

func (game *Game) SetKey(event map[string]interface{})

func (*Game) SetKeyStates

func (game *Game) SetKeyStates(kss *map[string]interface{})

type GameGrid

type GameGrid struct {
	// Standard tetris game field is 10 units wide and 22 units high, with the topmost 2 rows hidden
	Data [10 * 22]rune
}

Grid --------------------------------------------------------------------------------------------

func (*GameGrid) ApplySprite

func (g *GameGrid) ApplySprite(s []Vector, p Vector, t rune) int32

func (*GameGrid) Clear

func (g *GameGrid) Clear()

Grid methods

type Sprite

type Sprite struct {
	Data []Vector
}

type Tetromino

type Tetromino struct {
	Type    rune
	Sprites []Sprite
}

type TetrominoFactory

type TetrominoFactory struct {
	Inventory []Tetromino
}

func NewTetrominoFactory

func NewTetrominoFactory() TetrominoFactory

func (*TetrominoFactory) Next

func (tf *TetrominoFactory) Next() Tetromino

type Vector

type Vector struct {
	X int32
	Y int32
}

Jump to

Keyboard shortcuts

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