colordance
This commit is contained in:
@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
//fixme move to config
|
||||
var minRoomSize = 3
|
||||
var maxRoomSize = 11
|
||||
var maxrooms = 100
|
||||
var maxRoomSize = 22
|
||||
var maxrooms = 30
|
||||
|
||||
//fixme make closure to stack them
|
||||
func DefaultGen(l *gamemap.Level) *gamemap.Level {
|
||||
@ -35,27 +35,51 @@ func DefaultGen(l *gamemap.Level) *gamemap.Level {
|
||||
newRoom.Center = types.Coords{newRoom.X + newRoom.W / 2, newRoom.Y + newRoom.H / 2}
|
||||
|
||||
failed := false
|
||||
for _, otherRoom := range rooms {
|
||||
if otherRoom.Intersects(newRoom.Rect) {
|
||||
failed = true
|
||||
break
|
||||
|
||||
if !l.InBounds(types.Coords{newRoom.X, newRoom.Y}) {
|
||||
failed = true
|
||||
}
|
||||
|
||||
if !failed && !l.InBounds(types.Coords{newRoom.X + newRoom.W, newRoom.Y + newRoom.H}) {
|
||||
failed = true
|
||||
}
|
||||
|
||||
if !failed {
|
||||
for _, otherRoom := range rooms {
|
||||
if otherRoom.Intersects(newRoom.Rect) {
|
||||
failed = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !failed {
|
||||
rooms = append(rooms, newRoom)
|
||||
}
|
||||
}
|
||||
|
||||
//fillage := types.RectFill{
|
||||
// Top: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// Bottom: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// Left: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// Right: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// BottomLeft: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// BottomRight: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// TopLeft: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// TopRight: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
// Body: func() *gamemap.Tile {return gamemap.NewFloor()},
|
||||
//}
|
||||
|
||||
fillage := types.RectFill{
|
||||
Top: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
Bottom: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
Left: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
Right: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
BottomLeft: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
BottomRight: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
TopLeft: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
TopRight: func() *gamemap.Tile {return gamemap.NewWall()},
|
||||
Body: func() *gamemap.Tile {return gamemap.NewFloor()},
|
||||
Top: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
Bottom: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
Left: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
Right: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
BottomLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
BottomRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
TopLeft: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
TopRight: func() *gamemap.Tile {return gamemap.NewWaterTile()},
|
||||
Body: func() *gamemap.Tile {return gamemap.NewDeepWaterTile()},
|
||||
}
|
||||
|
||||
for idx, room := range rooms {
|
||||
@ -80,28 +104,33 @@ func connectRooms (l *gamemap.Level, room, otherRoom *gamemap.Room, fillage type
|
||||
|
||||
func digHTunnel(l *gamemap.Level, x1,x2,y int, fillage types.RectFill) {
|
||||
var start, finish int
|
||||
if x1 > x2 {
|
||||
if x1 < x2 {
|
||||
start = x1
|
||||
finish = x2
|
||||
} else {
|
||||
start = x2
|
||||
finish = x1
|
||||
}
|
||||
for i := start; i <= finish - 1; i++ {
|
||||
l.Tiles[i][y] = fillage.Body.(func() *gamemap.Tile)()
|
||||
for i := start; i <= finish; i++ {
|
||||
if l.InBounds(types.Coords{i, y}) {
|
||||
l.Tiles[i][y] = fillage.Body.(func() *gamemap.Tile)()
|
||||
//l.Tiles[i][y] = gamemap.NewFloor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func digVTunnel(l *gamemap.Level, y1,y2,x int, fillage types.RectFill) {
|
||||
var start, finish int
|
||||
if y1 > y2 {
|
||||
if y1 < y2 {
|
||||
start = y1
|
||||
finish = y2
|
||||
} else {
|
||||
start = y2
|
||||
finish = y1
|
||||
}
|
||||
for i := start; i <= finish - 1; i++ {
|
||||
l.Tiles[x][i] = fillage.Body.(func() *gamemap.Tile)()
|
||||
for i := start; i <= finish; i++ {
|
||||
if l.InBounds(types.Coords{x, i}) {
|
||||
l.Tiles[x][i] = fillage.Body.(func() *gamemap.Tile)()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user