goh

package
v0.0.0-...-eca66e6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 1024
	ScreenHeight = 1024
)
View Source
const (
	ActionNone = iota
	ActionDraw
	ActionErase
)

Variables

View Source
var (
	Image = ebiten.NewImage(3, 3)
)

Functions

func DrawCenteredText

func DrawCenteredText(screen *ebiten.Image, s string, font *text.GoTextFace, cx, cy int, color color.Color)

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func NewBoard

func NewBoard() map[Hex]*Cell

Types

type Cell

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

func (*Cell) AliveNextGen

func (c *Cell) AliveNextGen() bool

type FractionalHex

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

func (*FractionalHex) Round

func (fh *FractionalHex) Round() Hex

type Game

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

func NewGame

func NewGame() *Game

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

func (*Game) DrawHex

func (g *Game) DrawHex(screen *ebiten.Image, hex Hex, cell *Cell)

func (*Game) DrawInfo

func (g *Game) DrawInfo(screen *ebiten.Image)

func (*Game) GetCell

func (g *Game) GetCell(hex Hex) *Cell

func (*Game) GetCellColor

func (g *Game) GetCellColor(cell *Cell) float32

func (*Game) GetCellUnderCursor

func (g *Game) GetCellUnderCursor() *Cell

func (*Game) GetHexUnderCursor

func (g *Game) GetHexUnderCursor() Hex

func (*Game) GetNeighbors

func (g *Game) GetNeighbors(hex Hex) []*Cell

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

func (*Game) NextGen

func (g *Game) NextGen()

func (*Game) Start

func (g *Game) Start()

func (*Game) Stop

func (g *Game) Stop()

func (*Game) Update

func (g *Game) Update() error

func (*Game) UpdateBoardState

func (g *Game) UpdateBoardState()

type Hex

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

Hex space is represented by a cube coordinate system where q + r + s = 0

func AddHexes

func AddHexes(h1, h2 Hex) Hex

func (*Hex) ToString

func (h *Hex) ToString() string

type Layout

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

func NewLayout

func NewLayout(orientation *Orientation, size, origin Point) *Layout

func (*Layout) GetCorners

func (l *Layout) GetCorners(hex *Hex) []Point

func (*Layout) HexCornerOffset

func (l *Layout) HexCornerOffset(corner int) Point

func (*Layout) HexToPixel

func (l *Layout) HexToPixel(hex *Hex) Point

func (*Layout) PixelToHex

func (l *Layout) PixelToHex(p Point) Hex

type Orientation

type Orientation struct {
	// contains filtered or unexported fields
}
var FlatTop Orientation = Orientation{
	float32(3.0 / 2.0),
	float32(0.0),
	float32(math.Sqrt(3.0) / 2.0),
	float32(math.Sqrt(3.0)),
	float32(2.0 / 3.0),
	float32(0.0),
	float32(-1.0 / 3.0),
	float32(math.Sqrt(3.0) / 3.0),
	float32(0.0),
}
var PointyTop Orientation = Orientation{
	float32(math.Sqrt(3.0)),
	float32(math.Sqrt(3.0) / 2.0),
	float32(0.0),
	float32(3.0 / 2.0),
	float32(math.Sqrt(3.0) / 3.0),
	float32(-1.0 / 3.0),
	float32(0.0),
	float32(2.0 / 3.0),
	float32(0.5),
}

type Point

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

Coordinates in 2D space

Jump to

Keyboard shortcuts

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