board

package
v0.0.0-...-dfb1794 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWidthScale = 2
)

Defaults for board

Variables

This section is empty.

Functions

func BlockGridCells

func BlockGridCells(b [][]*Block, background canvas.Color, widthScale int) [][]canvas.Cell

BlockGridCells generates the visual representation of a grid of cells

Types

type Block

type Block struct {
	Color       canvas.Color
	Transparent bool
}

Block represents a single block on the board

type Board

type Board struct {
	Blocks [][]*Block
	// contains filtered or unexported fields
}

Board represents the game board

func New

func New(opts ...Option) *Board

New creates a new board

func (*Board) Background

func (b *Board) Background() canvas.Color

Background returns the boards background color

func (*Board) Cells

func (b *Board) Cells() [][]canvas.Cell

Cells generates a visual representation of the board

func (*Board) CheckRows

func (b *Board) CheckRows() []int

CheckRows checks if there are any full rows

func (*Board) ClearFullRows

func (b *Board) ClearFullRows() int

ClearFullRows checks if any rows are full and clears them if so

func (*Board) HiddenRows

func (b *Board) HiddenRows() int

HiddenRows returns the number of rows that will be excluded when rendering

type Option

type Option interface {
	ApplyToBoard(b *Board)
}

Option represents a configuration option for the board

func WithBackground

func WithBackground(c canvas.Color) Option

WithBackground returns an option specifies the background for the canvas and board

func WithHeight

func WithHeight(height int) Option

WithHeight returns an option the specifies the height of the board

func WithHiddenRows

func WithHiddenRows(rows int) Option

WithHiddenRows returns an option that specifies how many rows of the board shouldn't be rendered

func WithWidth

func WithWidth(width int) Option

WithWidth returns an option the specifies the width of the board

func WithWidthScale

func WithWidthScale(scale int) Option

WithWidthScale returns an option that specifies how blocks should be scaled to cells

Jump to

Keyboard shortcuts

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