Documentation ¶
Overview ¶
Package gendungeon implements a simple dungeon generator forked from https://github.com/brad811/go-dungeon which is in turn based on http://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( RoomAttempts = 200 MinRoomSize = 5 MaxRoomSize = 15 )
Suggested default values for the dungeon generation.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Width int Height int RoomAttempts int MinRoomSize int MaxRoomSize int AllowNonRect bool // Allow non-rectangular rooms. }
Config is a configuration for dungeon generation.
type Dungeon ¶
type Dungeon struct { Tiles [][]Tile // dungeon grid Rooms []Room // rooms in the dungeon Width int // width of the dungeon Height int // height of the dungeon // contains filtered or unexported fields }
Dungeon represents a generated dungeon.
func Generate ¶
Generate generates a new dungeon with the given width and height. Further parameters include the number of attempts to use to place rooms, the minimum and maximum room size, and the seed to use.
func GenerateFromConfig ¶
GenerateFromConfig generates a new dungeon with the given configuration.
func (*Dungeon) RenderToConsole ¶
func (dng *Dungeon) RenderToConsole()
RenderToConsole prints the dungeon layout to the console.
type DungeonMultiLevel ¶
type DungeonMultiLevel struct {
Levels []*Dungeon
}
DungeonMultiLevel represents a multi level dungeon.
func GenerateMultiLevelFromConfig ¶
func GenerateMultiLevelFromConfig(cfg Config, n int, seed int64) *DungeonMultiLevel
GenerateMultiLevelFromConfig generates a mult level dungeon.
func NewDungeonMultiLevel ¶
func NewDungeonMultiLevel() *DungeonMultiLevel
NewDungeonMultiLevel creates a new multi level dungeon.
func (*DungeonMultiLevel) AddLevel ¶
func (d *DungeonMultiLevel) AddLevel(level *Dungeon)
AddLevel adds a level to the dungeon.
func (*DungeonMultiLevel) CreateNLevels ¶
func (d *DungeonMultiLevel) CreateNLevels(cfg Config, n int, seed int64)
CreateNLevels creates n levels for the dungeon using the supplied config.
func (*DungeonMultiLevel) CreateStairs ¶
func (d *DungeonMultiLevel) CreateStairs()
CreateStairs creates stairs between levels. Call this after all levels have been created.
func (*DungeonMultiLevel) RenderToConsole ¶
func (d *DungeonMultiLevel) RenderToConsole()
RenderToConsole renders the dungeon to the console.
type Rect ¶
type Rect struct {
X, Y, Width, Height int
}
Rect is a rectangle with a specific width and height.
type Room ¶
type Room struct { Width int // width of the room Height int // height of the room Location Point // top left corner of the room Edges []Point // the edges of the room Style RoomStyle // style / shape of the room }
Room represents a room in the dungeon.