Documentation ¶
Index ¶
- func CountWalls(atlas [][]int, width, height int, gridX, gridY int) int
- func CreateTriangle(triangles []uint16, a, b, c Node) []uint16
- func InvertMap(atlas [][]int, width, height int) [][]int
- func RandomFillMap(w, h, percent int) (atlas [][]int)
- func SmoothMap(atlas [][]int, width, height int) [][]int
- type ControlNode
- type MapGenerator
- type MeshGenerator
- func (mg *MeshGenerator) AssignVertices(points []Node) []Node
- func (mg *MeshGenerator) GenerateMesh(atlas [][]int, squareSize float32)
- func (mg *MeshGenerator) GetTriangles() ([]ebiten.Vertex, []uint16)
- func (mg *MeshGenerator) MeshFromPoints(points ...Node)
- func (mg *MeshGenerator) TriangulateSquare(square Square)
- type Node
- type Square
- type SquareGrid
- type Triangle
- type Vector2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountWalls ¶
CountWalls gives the number of neighbors of a cell in a grid
func CreateTriangle ¶
CreateTriangle adds an aggregate indexes of three nodes/vertices
func RandomFillMap ¶
RandomFillMap fills map with random values if using random seed
Types ¶
type ControlNode ¶
type ControlNode struct {
// contains filtered or unexported fields
}
ControlNode contains current, above, and right nodes, and active
func NewControlNode ¶
func NewControlNode(pos Vector2, active bool, squareSize float32) *ControlNode
NewControlNode set an above node and right node depending on the given size when active
type MapGenerator ¶
type MapGenerator struct {
// contains filtered or unexported fields
}
MapGenerator contains map generator state
func NewMapGenerator ¶
func NewMapGenerator(randomFillPercent, width, height int, squareSize float32) *MapGenerator
NewMapGenerator instantiates a map
func (*MapGenerator) GenerateMap ¶
func (mg *MapGenerator) GenerateMap() error
GenerateMap generates map by filling, smoothing and generating mesh
func (*MapGenerator) GetTriangles ¶
func (mg *MapGenerator) GetTriangles() ([]ebiten.Vertex, []uint16)
GetTriangles returns the verteces and the indices after generating the mesh
type MeshGenerator ¶
type MeshGenerator struct {
// contains filtered or unexported fields
}
MeshGenerator provides struct for DrawTriangle based on the atlas from map generator
func (*MeshGenerator) AssignVertices ¶
func (mg *MeshGenerator) AssignVertices(points []Node) []Node
AssignVertices connects triangles' verteces to another point
func (*MeshGenerator) GenerateMesh ¶
func (mg *MeshGenerator) GenerateMesh(atlas [][]int, squareSize float32)
GenerateMesh generates mesh based on atlas, squareSize, and displacement
func (*MeshGenerator) GetTriangles ¶
func (mg *MeshGenerator) GetTriangles() ([]ebiten.Vertex, []uint16)
GetTriangles returns the verteces and the indices after generating the mesh
func (*MeshGenerator) MeshFromPoints ¶
func (mg *MeshGenerator) MeshFromPoints(points ...Node)
MeshFromPoints sets triangle points to meshes
func (*MeshGenerator) TriangulateSquare ¶
func (mg *MeshGenerator) TriangulateSquare(square Square)
TriangulateSquare translate square configs to ebiten verteces and indeces
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node gives position based on index
func (*Node) IsConsumed ¶
IsConsumed gives true if vertexIndex is already consumed or set
type Square ¶
type Square struct {
// contains filtered or unexported fields
}
Square ...
func NewSquare ¶
func NewSquare(topLeft, topRight, bottomRight, bottomLeft *ControlNode) *Square
NewSquare ...
type SquareGrid ¶
type SquareGrid struct {
// contains filtered or unexported fields
}
SquareGrid ...
func NewSquareGrid ¶
func NewSquareGrid(atlas [][]int, squareSize float32) *SquareGrid
NewSquareGrid ...