tetris

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2020 License: MIT Imports: 9 Imported by: 0

README

tetris

Build Status Go Report Card GoDoc GitHub license

The tritris implemented with golang

demo

License

Pouch is licensed under the MIT License. See LICENSE for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BlocksPool = [...]Blocks{
	{
		Blocks: []Block{

			0b_0000_1111_0000_0000,

			0b_0010_0010_0010_0010,

			0b_0000_0000_1111_0000,

			0b_0100_0100_0100_0100,
		},
		Color:   ctc.BackgroundBright.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundBright.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_1100_0110_0000,

			0b_0000_0010_0110_0100,

			0b_0000_0000_1100_0110,

			0b_0000_0100_1100_1000,
		},
		Color:   ctc.BackgroundRed.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundRed.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_0110_1100_0000,

			0b_0000_0100_0110_0010,

			0b_0000_0000_0110_1100,

			0b_0000_1000_1100_0100,
		},
		Color:   ctc.BackgroundGreen.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundGreen.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_1000_1110_0000,

			0b_0000_0110_0100_0100,

			0b_0000_0000_1110_0010,

			0b_0000_0100_0100_1100,
		},
		Color:   ctc.BackgroundBlue.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundBlue.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_0010_1110_0000,

			0b_0000_0100_0100_0110,

			0b_0000_0000_1110_1000,

			0b_0000_1100_0100_0100,
		},
		Color:   ctc.BackgroundCyan.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundCyan.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_0100_1110_0000,

			0b_0000_0100_0110_0100,

			0b_0000_0000_1110_0100,

			0b_0000_0100_1100_0100,
		},
		Color:   ctc.BackgroundMagenta.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundMagenta.String() + predictRune + ctc.Reset.String(),
	},

	{
		Blocks: []Block{

			0b_0000_0110_0110_0000,
		},
		Color:   ctc.BackgroundYellow.String() + blockRune + ctc.Reset.String(),
		Predict: ctc.ForegroundYellow.String() + predictRune + ctc.Reset.String(),
	},
}

Functions

This section is empty.

Types

type Block

type Block uint16

func (Block) On

func (b Block) On(x, y int) int

type Blocks

type Blocks struct {
	Blocks  []Block
	Color   string
	Predict string
}

type Command added in v0.1.2

type Command uint
const (
	None Command = iota
	Pause
	RightRotate
	LeftRotate
	RightMove
	LeftMove
	DownMove
	Drop
)

type Draw

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

func NewDraw

func NewDraw(out io.Writer) *Draw

func (*Draw) Block

func (b *Draw) Block(block Block, point string, cw int, x, y int)

func (*Draw) Box

func (b *Draw) Box(point string, cw int, x, y, w, h int)

func (*Draw) Clear

func (b *Draw) Clear()

func (*Draw) Dot

func (b *Draw) Dot(point string, cw int, x, y int)

type Tetris

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

func NewTetris

func NewTetris() *Tetris

func (*Tetris) Continue added in v0.1.2

func (t *Tetris) Continue()

func (*Tetris) DownMove added in v0.1.2

func (t *Tetris) DownMove()

func (*Tetris) Drop

func (t *Tetris) Drop()

func (*Tetris) Get

func (t *Tetris) Get(x, y int) string

func (*Tetris) IsGameOver

func (t *Tetris) IsGameOver() bool

func (*Tetris) IsPause added in v0.1.2

func (t *Tetris) IsPause() bool

func (*Tetris) LeftMove

func (t *Tetris) LeftMove()

func (*Tetris) LeftRotate

func (t *Tetris) LeftRotate()

func (*Tetris) On

func (t *Tetris) On(x, y int) int

func (*Tetris) Pause added in v0.1.2

func (t *Tetris) Pause()

func (*Tetris) RightMove

func (t *Tetris) RightMove()

func (*Tetris) RightRotate

func (t *Tetris) RightRotate()

func (*Tetris) Run

func (t *Tetris) Run(ctx context.Context, cch <-chan Command) (err error)

func (*Tetris) Set

func (t *Tetris) Set(x, y int, currentColor string)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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