chess

package module
v0.0.0-...-450dd1a Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

🚧 Go Chess

https://miketmoore.itch.io/chess

Go Report Card

🎮 Play

You can download the latest published binary from itch.io or build from source.

📦 Build and Run from Source

# Get dependencies, run tests, and build binary:
mkdir -p $GOPATH/src/github.com/miketmoore
cd $GOPATH/src/github.com/miketmoore
git clone github.com/miketmoore/chess
cd chess
make 

# Run 
./chess

📝 Credit

🎨 Custom Game Art - Work in Progress

I am drawing a set of chess pieces for this game. You can follow my progress on Flickr.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Themes = map[string]map[string]color.RGBA{
	"classic": map[string]color.RGBA{
		"black": color.RGBA{0, 0, 0, 255},
		"white": color.RGBA{255, 255, 255, 255},
	},
	"coral": map[string]color.RGBA{
		"black": color.RGBA{112, 162, 163, 255},
		"white": color.RGBA{177, 228, 185, 255},
	},
	"emerald": map[string]color.RGBA{
		"black": color.RGBA{111, 143, 114, 255},
		"white": color.RGBA{173, 189, 143, 255},
	},
	"sandcastle": map[string]color.RGBA{
		"black": color.RGBA{184, 139, 74, 255},
		"white": color.RGBA{227, 193, 111, 255},
	},
}

Themes is a collection of color themes for the board

Functions

func HighlightSquares

func HighlightSquares(win *pixelgl.Window, squares BoardMap, coords chessapi.ValidDestinations, color color.RGBA)

HighlightSquares adds a visual marker to the list of board squares

func NewPieceRenderer

func NewPieceRenderer(win *pixelgl.Window) (pieces, error)

NewPieceRenderer builds a pieces instance that is responsible for drawing chess pieces

Types

type Board

type Board struct {
	Squares              BoardMap
	SquareOriginByCoords map[chessapi.Coord][]float64
}

func NewBoard

func NewBoard(
	originX, originY, size float64,
	blackFill, whiteFill color.RGBA,
) Board

NewBoard returns an array of *imdraw.IMDraw instances, each representing one square on a chess boardview. The size argument defines the width and height of each square. The blackFill and whiteFill arguments define what colors are used for the "black" and "white" squares.

func (*Board) GetCoord

func (board *Board) GetCoord(vec pixel.Vec) (chessapi.Coord, bool)

type BoardMap

type BoardMap map[chessapi.Coord]Square

BoardMap is the type used to describe the map of board squares/shapes

type Square

type Square struct {
	Shape   *imdraw.IMDraw
	OriginX float64
	OriginY float64
}

Square represents one square of the board

func FindSquareByVec

func FindSquareByVec(squares BoardMap, vec pixel.Vec) *Square

FindSquareByVec finds a square from the board map by it's (x,y) coordinate

Directories

Path Synopsis
cmd
chess command

Jump to

Keyboard shortcuts

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