Documentation ¶
Index ¶
- Constants
- Variables
- func AvatarSVG(settings AvatarSettings) (string, error)
- func DrawBoard(b *Board, imageWidth, imageHeight int) image.Image
- func GameFrameToASCII(w io.Writer, g *engine.Game, gf *engine.GameFrame) error
- func GameFrameToGIF(w io.Writer, g *engine.Game, gf *engine.GameFrame, width, height int) error
- func GameFramesToAnimatedGIF(w io.Writer, g *engine.Game, gameFrames []*engine.GameFrame, ...) error
- type AvatarSettings
- type Board
- type BoardSquare
- type BoardSquareContent
- type BoardSquareContentType
Constants ¶
View Source
const ( ASCIIEmpty = " " ASCIIFood = "*" ASCIISnakeHead = "H" ASCIISnakeBody = "O" ASCIISnakeTail = "T" ASCIIHazard = "." )
View Source
const ( GIFFrameDelay = 8 GIFLoopDelay = 200 GIFMaxColorsPerFrame = 256 )
View Source
const ( BoardBorder float64 = 2 SquareBorderPixels float64 = 1 ColorEmptySquare = "#f0f0f0" ColorFood = "#ff5c75" ColorHazard = "#00000066" )
View Source
const ColorDeadSnake = "#cdcdcd"
ColorDeadSnake is the default hex colour used for displaying snakes that have died
Variables ¶
View Source
var ErrInvalidAvatarSettings = errors.New("invalid avatar settings")
Functions ¶
func AvatarSVG ¶
func AvatarSVG(settings AvatarSettings) (string, error)
func DrawBoard ¶
DrawBoard draws the given board data into an image. Width and height values are in pixels. If the image width/height is invalid (<= 0) a valid width/height is calculated using the number of squares in the board.
func GameFrameToASCII ¶
func GameFrameToGIF ¶
Types ¶
type AvatarSettings ¶
func (AvatarSettings) CalculateBodyWidth ¶
func (a AvatarSettings) CalculateBodyWidth() int
func (AvatarSettings) CalculateHeadOffset ¶
func (a AvatarSettings) CalculateHeadOffset() int
func (AvatarSettings) CopyrightNotice ¶
func (a AvatarSettings) CopyrightNotice() string
func (AvatarSettings) Validate ¶
func (a AvatarSettings) Validate() bool
type BoardSquare ¶
type BoardSquare struct {
Contents []BoardSquareContent
}
BoardSquare represents a unique location on the game board.
type BoardSquareContent ¶
type BoardSquareContent struct { Type BoardSquareContentType Color color.Color SnakeType string Direction snakeDirection Corner snakeCorner }
BoardSquareContent represents a single piece of content in a single square of the game board. Examples of content are food, snake body parts and hazard squares
type BoardSquareContentType ¶
type BoardSquareContentType int
BoardSquareContentType works like an enum. It provides a restricted set of types of content that can be placed in a board square.
const ( BoardSquareFood BoardSquareContentType = iota BoardSquareSnakeBody BoardSquareSnakeHead BoardSquareSnakeTail BoardSquareHazard )
Click to show internal directories.
Click to hide internal directories.