move to terrain render system
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"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/appctx"
|
||||
)
|
||||
|
||||
//fixme move to config
|
||||
@ -101,6 +102,15 @@ func GetRandomRoomList(ctx context.Context, rng *util.RNG, l *gamemap.Level, max
|
||||
return rooms
|
||||
}
|
||||
|
||||
func BlitToLevel (ctx context.Context, l *gamemap.Level, rooms[]gamemap.Room) {
|
||||
for _, room := range rooms {
|
||||
err := room.BlitToLevel(ctx, l)
|
||||
if err != nil {
|
||||
appctx.Logger(ctx).Err(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//delaunay helper funcs
|
||||
func MedianStraight(rng *util.RNG, l *gamemap.Level, rooms []gamemap.Room, centers []types.Coords, edge types.Edge) {
|
||||
//find connected rooms
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mapgens
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util/appctx"
|
||||
@ -20,12 +19,7 @@ func DefaultGen(ctx appctx.ClientCtx,l *gamemap.Level) (*gamemap.Level, []gamema
|
||||
|
||||
rooms := GetRandomRoomList(ctx, rng, l, maxrooms, minRoomSize, maxRoomSize)
|
||||
|
||||
for _, room := range rooms {
|
||||
err := room.BlitToLevel(l)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %v", err)
|
||||
}
|
||||
}
|
||||
BlitToLevel(ctx, l, rooms)
|
||||
|
||||
for idx, room := range rooms {
|
||||
if idx > 0 {
|
||||
|
@ -2,7 +2,6 @@ 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"
|
||||
@ -22,12 +21,7 @@ func DelaunayMstGen(ctx context.Context, l *gamemap.Level) (*gamemap.Level, []ga
|
||||
rooms := GetRandomRoomList(ctx, rng, l, maxrooms, minRoomSize, maxRoomSize)
|
||||
|
||||
|
||||
for _, room := range rooms {
|
||||
err := room.BlitToLevel(l)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %v", err)
|
||||
}
|
||||
}
|
||||
BlitToLevel(ctx, l, rooms)
|
||||
|
||||
centers := make([]types.Coords, 0)
|
||||
for _, room := range rooms {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package mapgens
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util"
|
||||
@ -21,13 +20,7 @@ func DelaunayMstExtGen(ctx appctx.ClientCtx, l *gamemap.Level) (*gamemap.Level,
|
||||
}
|
||||
rooms := GetRandomRoomList(ctx, rng, l, maxrooms, minRoomSize, maxRoomSize)
|
||||
|
||||
|
||||
for _, room := range rooms {
|
||||
err := room.BlitToLevel(l)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %v", err)
|
||||
}
|
||||
}
|
||||
BlitToLevel(ctx, l, rooms)
|
||||
|
||||
centers := make([]types.Coords, 0)
|
||||
for _, room := range rooms {
|
||||
|
@ -2,7 +2,6 @@ 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"
|
||||
@ -21,13 +20,7 @@ func DelaunayPureGen(ctx context.Context, l *gamemap.Level) (*gamemap.Level, []g
|
||||
}
|
||||
rooms := GetRandomRoomList(ctx, rng, l, maxrooms, minRoomSize, maxRoomSize)
|
||||
|
||||
|
||||
for _, room := range rooms {
|
||||
err := room.BlitToLevel(l)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %v", err)
|
||||
}
|
||||
}
|
||||
BlitToLevel(ctx, l, rooms)
|
||||
|
||||
centers := make([]types.Coords, 0)
|
||||
for _, room := range rooms {
|
||||
|
@ -1,12 +1,14 @@
|
||||
package gamemap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/items"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/mob"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/types"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util"
|
||||
"lab.zaar.be/thefish/alchemyst-go/util/appctx"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -31,7 +33,7 @@ func (r *Room) Put (x, y int, tileFunc interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (room *Room) BlitToLevel(l *Level) error {
|
||||
func (room *Room) BlitToLevel(ctx context.Context, l *Level) error {
|
||||
//copy tiles like this:
|
||||
//https://stackoverflow.com/questions/21011023/copy-pointer-values-a-b-in-golang
|
||||
|
||||
@ -49,7 +51,7 @@ func (room *Room) BlitToLevel(l *Level) error {
|
||||
//check underlying tile
|
||||
if underlyingTile == nil ||
|
||||
underlyingTile.Name != "Wall" {
|
||||
fmt.Println("Invalid blit!")
|
||||
appctx.Logger(ctx).Warn().Msg("Invalid blit!")
|
||||
return invalidBlit
|
||||
}
|
||||
l.Put(mapCoords.X, mapCoords.Y, tileFunc)
|
||||
|
Reference in New Issue
Block a user