Documentation
¶
Index ¶
- Constants
- func GetRandomColorInRgb() (c color.RGBA)
- func ParseHexColor(s string) (c color.RGBA, err error)
- type AreaMask
- type BitmapMask
- type Builder
- type CircleMask
- type DirectionCallback
- type DungeonCreationStrategy
- type DungeonData
- func (data *DungeonData) FindRoomForCoord(x, y int) (*RoomData, error)
- func (data *DungeonData) ForEachTile(fun func(x, y int, tile TileType, data *DungeonData))
- func (data *DungeonData) Get(x int, y int) TileType
- func (data *DungeonData) GetPath(x int, y int) uint8
- func (data *DungeonData) Init()
- func (data *DungeonData) IsOutside(x, y int) bool
- func (data *DungeonData) Set(x int, y int, tile TileType)
- func (data *DungeonData) SetPath(x int, y int, tile uint8)
- func (data *DungeonData) SetRoomPath(x, y, width, height int, tile uint8)
- type EmptyMask
- type Explorer
- type Exporter
- type ExporterFormat
- type MapData2D
- type PNGExporter
- type PathData2D
- type RandomRoomStrategy
- type RoomData
- func (r *RoomData) AddDoor(direction int, pos Vec2D)
- func (r *RoomData) Collides(r2 RoomData) bool
- func (r *RoomData) Doors() []RoomDoor
- func (r *RoomData) Extrude(factor int) *RoomData
- func (r *RoomData) GetWallForPosition(x, y int) (int, error)
- func (r *RoomData) HasDoor(direction int) bool
- func (r *RoomData) IsCorner(x, y int) bool
- func (r *RoomData) IsInside(x, y int) bool
- type RoomDensity
- type RoomDoor
- type TileType
- type Vec2D
Constants ¶
const ( DirectionWest = 0 DirectionNorth = 1 DirectionEast = 2 DirectionSouth = 3 )
const ( RoomDensityLow RoomDensity = 1 RoomDensityMedium = 2 RoomDensityHigh = 3 RoomDensityMax = 4 )
Variables ¶
This section is empty.
Functions ¶
func GetRandomColorInRgb ¶
Types ¶
type BitmapMask ¶
func (*BitmapMask) IsInside ¶
func (bm *BitmapMask) IsInside(x, y int) bool
check if mask is white at that point
type Builder ¶
type Builder interface {
Build() *DungeonData
WithSmallSize() Builder
WithMask(mask AreaMask) Builder
WithSize(width int, height int) Builder
WithCreationStrategy(strategy DungeonCreationStrategy) Builder
}
Builder ..
type CircleMask ¶
CircleMask ...
func (*CircleMask) IsInside ¶
func (cm *CircleMask) IsInside(x, y int) bool
IsInside tet for CircleMask
type DirectionCallback ¶
type DirectionCallback struct {
DirectionCallbackWest func()
DirectionCallbackNorth func()
DirectionCallbackEast func()
DirectionCallbackSouth func()
}
func NewDirectionCallback ¶
func NewDirectionCallback(west, north, east, south func()) *DirectionCallback
func (*DirectionCallback) On ¶
func (dc *DirectionCallback) On(direction int)
type DungeonCreationStrategy ¶
type DungeonCreationStrategy interface {
Create(data *DungeonData, mask AreaMask)
}
DungeonCreationStrategy ...
type DungeonData ¶
type DungeonData struct {
Width int
Height int
MapData MapData2D
PathData PathData2D
Rooms []*RoomData
}
DungeonData ...
func (*DungeonData) FindRoomForCoord ¶
func (data *DungeonData) FindRoomForCoord(x, y int) (*RoomData, error)
FindRoomForCoord ...
func (*DungeonData) ForEachTile ¶
func (data *DungeonData) ForEachTile(fun func(x, y int, tile TileType, data *DungeonData))
func (*DungeonData) IsOutside ¶
func (data *DungeonData) IsOutside(x, y int) bool
IsOutside checks if coords are outside of the dungeon space
func (*DungeonData) SetPath ¶
func (data *DungeonData) SetPath(x int, y int, tile uint8)
SetPath ...
func (*DungeonData) SetRoomPath ¶
func (data *DungeonData) SetRoomPath(x, y, width, height int, tile uint8)
SetRoomPath ...
type Explorer ¶
type Explorer struct {
}
Explorer is used to explore a generated dungeon and create walkable path to be able to generate an interactive story
func NewExplorer ¶
func NewExplorer() *Explorer
NewExplorer convenience function to create an explorer instance
func (*Explorer) Explore ¶
func (e *Explorer) Explore(data *DungeonData)
Explore starts the dungeon exploring
type Exporter ¶
type Exporter interface {
Export(data DungeonData, format ExporterFormat) interface{}
}
Exporter exports data according to format
type ExporterFormat ¶
type ExporterFormat int8
ExporterFormat is the format used for exporter the DungeonData
const ( FormatPNG ExporterFormat = iota + 1 FormatJSON )
type PNGExporter ¶
type PNGExporter struct {
}
func (*PNGExporter) ExportAsFile ¶
func (exp *PNGExporter) ExportAsFile(data DungeonData, format ExporterFormat, fileName string) interface{}
Export PNG
func (*PNGExporter) ExportAsImage ¶
func (exp *PNGExporter) ExportAsImage(data DungeonData, format ExporterFormat) *image.Image
Export PNG
type RandomRoomStrategy ¶
type RandomRoomStrategy struct {
Density RoomDensity
MaxRooms int
UseRandomSeed bool
Seed int
MaxRoomWidth int
MaxRoomHeight int
MinRoomWidth int
MinRoomHeight int
SpaceBetweenRooms int
ChanceOfAdjacentRooms int
ChanceForDivergence int
RoomConnectedness int
}
RandomRoomStrategy...
func NewRandomRoomStrategy ¶
func NewRandomRoomStrategy() *RandomRoomStrategy
NewRandomRoomStrategy returns a default RandomRoomStrategy
func (*RandomRoomStrategy) Create ¶
func (strategy *RandomRoomStrategy) Create(data *DungeonData, mask AreaMask)
Create ...
type RoomData ¶
type RoomData struct {
X int
Y int
Width int
Height int
IsConnected bool
Visited bool
Section uint8
// contains filtered or unexported fields
}
RoomData ...
func NewRoomData ¶
NewRoomData creates a new room data instance
func (*RoomData) GetWallForPosition ¶
GetWallForPosition ...
type RoomDensity ¶
type RoomDensity int8