game

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HomeRowName   = "home-row"
	ArrowKeysName = "arrow-keys"
	StandardName  = "standard"
)

the available schemes

View Source
const (
	BeginnerDifficulty = "beginner"
	NoviceDifficulty   = "novice"
	ProDifficulty      = "pro"
	ExpertDifficulty   = "expert"
)

the available starting difficulties

Variables

This section is empty.

Functions

func LevelFromDifficulty

func LevelFromDifficulty(difficulty string) (int, error)

LevelFromDifficulty retrieves the starting level associated with a specified difficulty

Types

type ControlScheme

type ControlScheme interface {
	Description() string
	String() string
	// contains filtered or unexported methods
}

ControlScheme represents a mapping of keys to user input

func ArrowKeys

func ArrowKeys() ControlScheme

ArrowKeys represents the control scheme which utilizes the arrow keys

func AvailableSchemes

func AvailableSchemes() []ControlScheme

AvailableSchemes represents the set of available control schemes

func HomeRow

func HomeRow() ControlScheme

HomeRow represents the control scheme which focuses on the home row

func SchemeFromName

func SchemeFromName(name string) (ControlScheme, error)

SchemeFromName retrieves the scheme associated with the specified name

func Standard

func Standard() ControlScheme

Standard represents a control scheme similar to the standard tetrix keyboard controls

type ControlSchemes

type ControlSchemes []ControlScheme

ControlSchemes is a union of one or more mappings of keys to user input

func (ControlSchemes) Description

func (c ControlSchemes) Description() string

Description is the combined descriptions of multiple schemes

func (ControlSchemes) String

func (c ControlSchemes) String() string

type Game

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

Game is responsible for handling the game state

func New

func New(termReader io.Reader, termWriter io.Writer, opts ...Option) *Game

New returns a new game with the specified specifications

func (*Game) DisplayPotentialColors

func (g *Game) DisplayPotentialColors() error

DisplayPotentialColors prints a demo board with the potential pieces and colors This is used to assist the user in selecting options e.g. WithoutGhost() should be applied if ghost pieces render oddly in the canvas

func (*Game) Run

func (g *Game) Run(done chan bool) (chan int, chan error)

Run takes care of the core game functionality

type Option

type Option interface {
	Apply(g *Game)
}

Option represents a game option

func WithBackground

func WithBackground(c canvas.Color) Option

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

func WithColor

func WithColor(c canvas.Color) Option

WithColor returns an option specifies the primary color for the game

func WithControlScheme

func WithControlScheme(scheme ControlScheme) Option

WithControlScheme returns an Option which specifies the control scheme

func WithDebugMode

func WithDebugMode() Option

WithDebugMode returns an option that specifies that the game and canvas should use debug behaviour

func WithDimensions

func WithDimensions(d dimensions) Option

WithDimensions returns an option that specifies the dimensions of the board and canvas

func WithHiddenRows

func WithHiddenRows(rows int) Option

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

func WithInitialLevel

func WithInitialLevel(level int) Option

WithInitialLevel returns an option that specifies the initial level

func WithoutGhost

func WithoutGhost() Option

WithoutGhost returns an option that disables the ghost piece

func WithoutSide

func WithoutSide() Option

WithoutSide returns an option that disables the side bar

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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