delaunnay pure impl
This commit is contained in:
parent
cc017e3781
commit
7b4a3c3200
@ -74,6 +74,7 @@ func main() {
|
|||||||
//level, rooms := _default.DefaultGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
//level, rooms := _default.DefaultGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
||||||
//level, rooms := mapgens.DelaunayMstGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
//level, rooms := mapgens.DelaunayMstGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
||||||
level, rooms := mapgens.DelaunayMstExtGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
level, rooms := mapgens.DelaunayMstExtGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
||||||
|
//level, rooms := mapgens.DelaunayPureGen(mainCtx, gamemap.NewLevel(mainCtx, "test", 1))
|
||||||
State.Level = level
|
State.Level = level
|
||||||
|
|
||||||
sidebarWidth := 0
|
sidebarWidth := 0
|
||||||
|
@ -40,7 +40,7 @@ func DelaunayMstExtGen(ctx appctx.ClientCtx, l *gamemap.Level) (*gamemap.Level,
|
|||||||
MedianStraight(rng, l, rooms, centers, edge)
|
MedianStraight(rng, l, rooms, centers, edge)
|
||||||
outlyingCorridors = append(outlyingCorridors, edge)
|
outlyingCorridors = append(outlyingCorridors, edge)
|
||||||
outlyingCorrCount++
|
outlyingCorrCount++
|
||||||
if outlyingCorrCount > 5 {
|
if outlyingCorrCount > 8 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
engine/gamemap/mapgens/delaunay_pure.go
Normal file
45
engine/gamemap/mapgens/delaunay_pure.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package mapgens
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
|
||||||
|
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||||
|
"lab.zaar.be/thefish/alchemyst-go/util"
|
||||||
|
"lab.zaar.be/thefish/alchemyst-go/util/delaunay"
|
||||||
|
)
|
||||||
|
|
||||||
|
func DelaunayPureGen(ctx context.Context, l *gamemap.Level) (*gamemap.Level, []gamemap.Room) {
|
||||||
|
|
||||||
|
rng := util.NewRNG()
|
||||||
|
|
||||||
|
//fill with walls
|
||||||
|
for i := 0; i < l.W; i ++ {
|
||||||
|
for j := 0; j < l.H; j++ {
|
||||||
|
l.SetTileByXY(i, j, gamemap.NewWall())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rooms := GetRandomRoomList(ctx, rng, l, maxrooms, minRoomSize, maxRoomSize)
|
||||||
|
|
||||||
|
|
||||||
|
for _, room := range rooms {
|
||||||
|
err := room.BlitToLevel(l)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("err: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
centers := make([]types.Coords, 0)
|
||||||
|
for _, room := range rooms {
|
||||||
|
centers = append(centers, room.Center)
|
||||||
|
}
|
||||||
|
edges := delaunay.GetTriangles(centers, l.W, l.H)
|
||||||
|
for _, edge := range edges {
|
||||||
|
MedianStraight(rng, l, rooms, centers, edge)
|
||||||
|
}
|
||||||
|
|
||||||
|
return l, rooms
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user