From e30aa337150cbadf4dd4361bdbd135151ade46df Mon Sep 17 00:00:00 2001 From: thefish Date: Mon, 11 Nov 2019 01:47:16 +0300 Subject: [PATCH] mapgen moving to delanay -> minimum spanning tree for rooms connection --- Makefile | 6 +- .../fonts/bitmap}/ibmnew8x12.png | Bin .../fonts/ttf}/LiberationMono-Bold.ttf | Bin .../fonts/ttf}/UbuntuMono-R.ttf | Bin assets/prefabs/test.json | 39 ++++++ cmd/game/main.go | 2 +- cmd/mapeditor/editor.go | 6 + config.json | 2 +- engine/gamemap/level.go | 4 - engine/gamemap/mapgens/default.go | 113 +++++++--------- engine/gamemap/prefab.go | 124 ++++++++++++++++++ engine/gamemap/room.go | 85 ++++++++++++ go.mod | 7 + go.sum | 46 +++++++ prefab_test.go | 17 +++ ui/mainwindow/mainwindow.go | 2 +- 16 files changed, 380 insertions(+), 73 deletions(-) rename {resources/fonts-bitmap => assets/fonts/bitmap}/ibmnew8x12.png (100%) rename {resources/fonts-ttf => assets/fonts/ttf}/LiberationMono-Bold.ttf (100%) rename {resources/fonts-ttf => assets/fonts/ttf}/UbuntuMono-R.ttf (100%) create mode 100644 assets/prefabs/test.json create mode 100644 engine/gamemap/prefab.go create mode 100644 engine/gamemap/room.go create mode 100644 prefab_test.go diff --git a/Makefile b/Makefile index 1492f0a..771c1e1 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ build.game.linux64: php update-config-version.php cp $(CWD)/vendor/lab.zaar.be/thefish/bearlibterminal/libBearLibTerminal.so $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ - cp -r $(CWD)/resources $(DISTFOLDER) && \ + cp -r $(CWD)/assets $(DISTFOLDER) && \ $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game && \ chmod +x $(DISTFOLDER)/game && \ @@ -40,7 +40,7 @@ build.game.win64: php update-config-version.php cp $(CWD)/lib/win64/BearLibTerminal.dll $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ - cp -r $(CWD)/resources $(DISTFOLDER) && \ + cp -r $(CWD)/assets $(DISTFOLDER) && \ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ $(GO) build -o $(DISTFOLDER)/game.exe -ldflags $(LDFLAGS) $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* @@ -48,7 +48,7 @@ build.game.win64: build.game.mac: cp $(CWD)/lib/mac/libBearLibTerminal.dylib $(DISTFOLDER) && \ cp $(CWD)/config.json $(DISTFOLDER) && \ - cp -r $(CWD)/resources $(DISTFOLDER) && \ + cp -r $(CWD)/assets $(DISTFOLDER) && \ OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=o64-clang CXX=o64-clang++ GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 $(GO) build -ldflags $(LDFLAGS) -o $(DISTFOLDER)/game $(CWD)/cmd/game/main.go && \ strip $(DISTFOLDER)/game.exe && \ cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git* diff --git a/resources/fonts-bitmap/ibmnew8x12.png b/assets/fonts/bitmap/ibmnew8x12.png similarity index 100% rename from resources/fonts-bitmap/ibmnew8x12.png rename to assets/fonts/bitmap/ibmnew8x12.png diff --git a/resources/fonts-ttf/LiberationMono-Bold.ttf b/assets/fonts/ttf/LiberationMono-Bold.ttf similarity index 100% rename from resources/fonts-ttf/LiberationMono-Bold.ttf rename to assets/fonts/ttf/LiberationMono-Bold.ttf diff --git a/resources/fonts-ttf/UbuntuMono-R.ttf b/assets/fonts/ttf/UbuntuMono-R.ttf similarity index 100% rename from resources/fonts-ttf/UbuntuMono-R.ttf rename to assets/fonts/ttf/UbuntuMono-R.ttf diff --git a/assets/prefabs/test.json b/assets/prefabs/test.json new file mode 100644 index 0000000..6559867 --- /dev/null +++ b/assets/prefabs/test.json @@ -0,0 +1,39 @@ +{ + "default_tile_legend": { + "?": "any", + "#": "wall", + ".": "floor", + "+": "connector" + }, + "default_mobs_legend": {}, + "default_item_legend": {}, + + "prefabs": [ + {"name": "test_room_1", + "tile_legend": { + "D": "decorated_wall", + "w": "water", + "W": "deep_water" + }, + "mobs_legend": {}, + "item_legend": {}, + "size": {"x":16, "y":13}, + "body": [ + "???????#+#??????", + "???DDDD#.#DDDD??", + "###D.........DD?", + "+....wwwwwww..D?", + "###..wWWWWWw..D?", + "??#..wW...Ww..##", + "??D..wW.D.Ww...+", + "??D..wW...Ww..##", + "??D..wWWWWWw..#?", + "??D..wwwwwww..D?", + "??DD.........DD?", + "???DDDD#.#DDDD??", + "???????#+#??????" + ] + + } + ] +} diff --git a/cmd/game/main.go b/cmd/game/main.go index 6474f0e..33c79b5 100644 --- a/cmd/game/main.go +++ b/cmd/game/main.go @@ -256,7 +256,7 @@ func decodeInput(ctx util.ClientCtx, baseLayer *mainwindow.Layer) { //fixme testing only case "F10": State.Do(func() { - blt.Set("window: size=100x47; font: ./resources/fonts-ttf/UbuntuMono-R.ttf, size=11;") + blt.Set("window: size=100x47; font: ./assets/ttf/UbuntuMono-R.ttf, size=11;") }) case "Ctrl+q": //fallthrough diff --git a/cmd/mapeditor/editor.go b/cmd/mapeditor/editor.go index 06ab7d0..876d0a2 100644 --- a/cmd/mapeditor/editor.go +++ b/cmd/mapeditor/editor.go @@ -1 +1,7 @@ package main + +import "lab.zaar.be/thefish/alchemyst-go/engine/gamemap" + +func main() { + _ = gamemap.PrefabRoomsList() +} \ No newline at end of file diff --git a/config.json b/config.json index ce33f4f..8b5907a 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "sizeX": 100, "sizeY": 47, "fpsLimit": 60, - "font": "./resources/fonts-ttf/LiberationMono-Bold.ttf", + "font": "./assets/fonts/ttf/LiberationMono-Bold.ttf", "fontSize": "9x14", "verbosity": "debug" } \ No newline at end of file diff --git a/engine/gamemap/level.go b/engine/gamemap/level.go index 2ca205f..1e06b5b 100644 --- a/engine/gamemap/level.go +++ b/engine/gamemap/level.go @@ -82,7 +82,3 @@ func (l *Level) SetAllInvisible() { } } -type Room struct { - *types.Rect - Center types.Coords -} \ No newline at end of file diff --git a/engine/gamemap/mapgens/default.go b/engine/gamemap/mapgens/default.go index b065cb9..62eca14 100644 --- a/engine/gamemap/mapgens/default.go +++ b/engine/gamemap/mapgens/default.go @@ -5,12 +5,38 @@ import ( "lab.zaar.be/thefish/alchemyst-go/engine/types" "lab.zaar.be/thefish/alchemyst-go/util" ) + //fixme move to config var minRoomSize = 3 var maxRoomSize = 22 var maxrooms = 50 -//fixme make closure to stack them +var fges = map[int]types.RectFill{ + 1: 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() }, + }, + + 2: types.RectFill{ + 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() }, + }, +} + func DefaultGen(l *gamemap.Level) (*gamemap.Level, []*gamemap.Room) { rng := util.NewRNG() @@ -24,35 +50,26 @@ func DefaultGen(l *gamemap.Level) (*gamemap.Level, []*gamemap.Room) { rooms := make([]*gamemap.Room, 0) - //one wall around whole level guaranteed - levelBoundary := types.NewRect(l.X + 1, l.Y + 1, l.W - 2, l.H - 2) - for i := 0; i < maxrooms; i++ { - newRoom := &gamemap.Room{ - Rect: types.NewRect( - rng.Range(l.X, l.W), - rng.Range(l.Y, l.H), - rng.Range(minRoomSize, maxRoomSize), - rng.Range(minRoomSize, maxRoomSize), - )} - newRoom.Center = types.Coords{newRoom.X + newRoom.W / 2, newRoom.Y + newRoom.H / 2} - - failed := false - - if !levelBoundary.InBounds(types.Coords{newRoom.X, newRoom.Y}) { - failed = true + var failed = false + var fillage types.RectFill + fillage = fges[rng.GetWeightedEntity(map[int]int{1: 10, 2: 1})] + newRoom := gamemap.NewRandomRectRoom( + rng, + rng.Range(minRoomSize, maxRoomSize), + rng.Range(minRoomSize, maxRoomSize), + fillage, + ) + where := types.Coords{ + rng.Range(1, l.W -2 - newRoom.W), + rng.Range(1, l.H - 2 - newRoom.H), } - 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 - } + for _, otherRoom := range rooms { + if otherRoom.Intersects(newRoom.Rect) { + failed = true + break } } @@ -60,61 +77,31 @@ func DefaultGen(l *gamemap.Level) (*gamemap.Level, []*gamemap.Room) { rooms = append(rooms, newRoom) } + newRoom.BlitToLevel(l, where) //addStairs(rooms) //itemize(rooms) } - fges := map[int]types.RectFill{ - 1: 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() }, - }, - - 2: types.RectFill{ - 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() }, - }, - } - - var fillage types.RectFill - for _, room := range rooms { - fillage = fges[rng.GetWeightedEntity(map[int]int{1:10, 2:1})] - room.Blit(fillage, l) - } for idx, room := range rooms { if idx > 0 { - connectRooms(l, room, rooms[idx-1], fillage, rng.Range(0,1)) + connectRooms(l, room, rooms[idx-1], fillage, rng.Range(0, 1)) } } return l, rooms } -func connectRooms (l *gamemap.Level, room, otherRoom *gamemap.Room, fillage types.RectFill, toss int) { +func connectRooms(l *gamemap.Level, room, otherRoom *gamemap.Room, fillage types.RectFill, toss int) { if toss == 0 { - digHTunnel(l, room.Center.X,otherRoom.Center.X,room.Center.Y, fillage) - digVTunnel(l, room.Center.Y,otherRoom.Center.Y,otherRoom.Center.X, fillage) + digHTunnel(l, room.Center.X, otherRoom.Center.X, room.Center.Y, fillage) + digVTunnel(l, room.Center.Y, otherRoom.Center.Y, otherRoom.Center.X, fillage) } else { digVTunnel(l, room.Center.Y, otherRoom.Center.Y, room.Center.Y, fillage) digHTunnel(l, room.Center.X, otherRoom.Center.X, otherRoom.Center.Y, fillage) } } -func digHTunnel(l *gamemap.Level, x1,x2,y int, fillage types.RectFill) { +func digHTunnel(l *gamemap.Level, x1, x2, y int, fillage types.RectFill) { var start, finish int if x1 < x2 { start = x1 @@ -131,7 +118,7 @@ func digHTunnel(l *gamemap.Level, x1,x2,y int, fillage types.RectFill) { } } -func digVTunnel(l *gamemap.Level, y1,y2,x int, fillage types.RectFill) { +func digVTunnel(l *gamemap.Level, y1, y2, x int, fillage types.RectFill) { var start, finish int if y1 < y2 { start = y1 diff --git a/engine/gamemap/prefab.go b/engine/gamemap/prefab.go new file mode 100644 index 0000000..456be2a --- /dev/null +++ b/engine/gamemap/prefab.go @@ -0,0 +1,124 @@ +package gamemap + +import ( + "encoding/json" + "fmt" + "io/ioutil" + "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" +) + +type PrefabFile struct { + DefaultTileLegend map[string]string `json:"default_tile_legend"` + DefaultMobsLegend map[string]string `json:"default_mobs_legend"` + DefaultItemLegend map[string]string `json:"default_item_legend"` + Prefabs []PrefabRecord +} + +type PrefabRecord struct { + name string + Size struct { + X int `json:"x"` + Y int `json:"y"` + } `json:"Size"` + TileLegend map[string]string `json:"default_tile_legend"` + MobsLegend map[string]string `json:"default_mobs_legend"` + ItemLegend map[string]string `json:"default_item_legend"` + Body []string `json:"body"` +} + +func LoadPrefabFile(filename string) (*PrefabFile, error) { + data, err := ioutil.ReadFile(filename) + if err!= nil { + return nil, err + } + instance := &PrefabFile{} + err = json.Unmarshal(data, instance) + if err != nil { + return nil, err + } + return instance, nil +} + +type PrefabLoader struct { + ctx util.ClientCtx +} + +func NewPrefabLoader(ctx util.ClientCtx) PrefabLoader { + return PrefabLoader{ctx: ctx} +} + +func (pfbl PrefabLoader) PrefabRoomsList() []Room { + + rooms := make([]Room, 0) + file, err := LoadPrefabFile("./assets/prefabs/test.json") + if err !=nil { + panic(err) + } + + for _, rawPrefab := range file.Prefabs { + //prepare actual legends + currentTileLegend := file.DefaultTileLegend + currentMobsLegend := file.DefaultMobsLegend + currentItemLegend := file.DefaultItemLegend + + fmt.Printf("%v",rawPrefab) + for k,v := range rawPrefab.TileLegend { + currentTileLegend[k] = v + } + for k,v := range rawPrefab.MobsLegend { + currentMobsLegend[k] = v + } + for k,v := range rawPrefab.ItemLegend { + currentItemLegend[k] = v + } + + room := Room{ + Rect:&types.Rect{0, 0, rawPrefab.Size.X, rawPrefab.Size.Y}, + Center: types.Coords{rawPrefab.Size.X / 2, rawPrefab.Size.Y / 2}, //fixme + Geometry: make([]func()*Tile, rawPrefab.Size.X*rawPrefab.Size.Y), + Mobs: make([]mob.Mob, rawPrefab.Size.X*rawPrefab.Size.Y), + Items: make([]items.Carried, rawPrefab.Size.X*rawPrefab.Size.Y), + Connectors: make([]types.Coords, rawPrefab.Size.X*rawPrefab.Size.Y), + } + //make geometry + var f func() *Tile + + for j := 0; j < room.H; j++ { + str := rawPrefab.Body[j] + if len(str) != room.W { + continue; + } + for i:=0; i < room.W; i++ { + ok := false + shortName := currentTileLegend[string(str[i])] + if shortName == "any" { + continue + } + if shortName == "connector" { + f = NewFloor + room.Connectors = append(room.Connectors, types.Coords{i,j}) + } else { + f, ok = TileTypeMap[shortName] + } + if (!ok) { + pfbl.ctx.Logger().Warn().Msgf("Unknown tile: %s", shortName) + } + room.Geometry[i+ j*room.W] = f + } + } + //add room to list + rooms = append(rooms, room) + } + return rooms +} + +var TileTypeMap = map[string]func()*Tile{ + "wall": NewWall, + "floor": NewFloor, + "decorated_wall": NewDecoratedWall, + "water": NewWaterTile, + "deep_water": NewDeepWaterTile, +} \ No newline at end of file diff --git a/engine/gamemap/room.go b/engine/gamemap/room.go new file mode 100644 index 0000000..4471d96 --- /dev/null +++ b/engine/gamemap/room.go @@ -0,0 +1,85 @@ +package gamemap + +import ( + "errors" + "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" +) + +var invalidBlit = errors.New("trying to blit on existing good tile") + +type Room struct { + *types.Rect + Center types.Coords + Geometry []func() *Tile + Mobs []mob.Mob + Items []items.Carried + Connectors []types.Coords +} + +func (r *Room) Put (x, y int, tileFunc interface{}) { + tf := tileFunc.(func() *Tile) + if tf == nil { + return //fixme error + } + if r.InBounds(types.Coords{x, y}) { + r.Geometry[x+y*r.W] = tf + } +} + +func (room *Room) BlitToLevel(l *Level, where types.Coords) error { + //copy tiles like this: + //https://stackoverflow.com/questions/21011023/copy-pointer-values-a-b-in-golang + + for j := 0; j < room.H; j++ { + + for i := 0; i < room.W; i++ { + underlyingTile := l.GetTileByXY(i+where.X, j+where.Y) + + tileFunc := room.Geometry[i+j*room.W] + + if tileFunc == nil { + continue + } + //check underlying tile + if underlyingTile != nil || + underlyingTile.Name != "Wall" { + return invalidBlit + } + l.Put(i+where.X, j+where.Y, tileFunc) + } + } + //update room coords? + room.X = where.X + room.Y = where.Y + //update connector? + for i, _ := range room.Connectors { + room.Connectors[i].X += where.X + room.Connectors[i].Y += where.Y + } + return nil +} + +func NewRandomRectRoom(rng *util.RNG, w, h int, fillage types.RectFill) *Room { + newRoom := &Room{ + Rect: types.NewRect( + 0, + 0, + w, + h, + ), + Center: types.Coords{w / 2, h /2 }, + } + newRoom.Blit(fillage, newRoom) + //add connectors + newRoom.Connectors = append( + newRoom.Connectors, + types.Coords{rng.Range(1, w - 2), 0}, + types.Coords{rng.Range(1, w - 2), h -1}, + types.Coords{0, rng.Range(1, h - 2)}, + types.Coords{w - 1, rng.Range(1, h - 2)}, + ) + return newRoom +} diff --git a/go.mod b/go.mod index bedfbfa..3d74214 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,14 @@ module lab.zaar.be/thefish/alchemyst-go go 1.12 require ( + github.com/esimov/triangle v1.0.4 // indirect + github.com/fogleman/astar v0.0.0-20160904014929-93992825fbf3 // indirect + github.com/fogleman/gg v1.3.0 // indirect github.com/gammazero/deque v0.0.0-20190521012701-46e4ffb7a622 github.com/rs/zerolog v1.15.0 + golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136 // indirect + golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect + golang.org/x/tools v0.0.0-20191109212701-97ad0ed33101 // indirect + gonum.org/v1/gonum v0.6.0 // indirect lab.zaar.be/thefish/bearlibterminal v0.0.0-20191018101635-dd37bbc90d77 ) diff --git a/go.sum b/go.sum index 7d9ca82..8f6017f 100644 --- a/go.sum +++ b/go.sum @@ -1,16 +1,62 @@ +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/esimov/triangle v1.0.4 h1:vmEwL5zBPRbN5+GmJE5Dk38IV/v8Zkdp34+yaGr4zrY= +github.com/esimov/triangle v1.0.4/go.mod h1:EKT/GJbKyDWK5IdEgx+wKjcj6zI0Wd27+p2zRgjfdKo= +github.com/fogleman/astar v0.0.0-20160904014929-93992825fbf3 h1:H1UdXUq3kFKSHmoISZ+B3EWukjHvAg8y9VFYO3bXHB8= +github.com/fogleman/astar v0.0.0-20160904014929-93992825fbf3/go.mod h1:oaWu1Maoxg5V3KjA0zGlhwwLAalGLjOFGFblaiHLwMc= +github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/gammazero/deque v0.0.0-20190521012701-46e4ffb7a622 h1:lxbhOGZ9pU3Kf8P6lFluUcE82yVZn2EqEf4+mWRNPV0= github.com/gammazero/deque v0.0.0-20190521012701-46e4ffb7a622/go.mod h1:D90+MBHVc9Sk1lJAbEVgws0eYEurY4mv2TDso3Nxh3w= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.15.0 h1:uPRuwkWF4J6fGsJ2R0Gn2jB1EQiav9k3S6CSdygQJXY= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2 h1:y102fOLFqhV41b+4GPiJoa0k/x+pJcEi2/HB1Y5T6fU= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136 h1:A1gGSx58LAGVHUUsOf7IiR0u8Xb6W51gRwfDBhkdcaw= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc h1:N3zlSgxkefUH/ecsl37RWTkESTB026kmXzNly8TuZCI= golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191109212701-97ad0ed33101 h1:LCmXVkvpQCDj724eX6irUTPCJP5GelFHxqGSWL2D1R0= +golang.org/x/tools v0.0.0-20191109212701-97ad0ed33101/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.6.0 h1:DJy6UzXbahnGUf1ujUNkh/NEtK14qMo2nvlBPs4U5yw= +gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= +gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= +gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= lab.zaar.be/thefish/bearlibterminal v0.0.0-20191018101635-dd37bbc90d77 h1:ElfFSOSxp1PViWH7+iKZ8sZvEhaKN9o3vt13+hX2yaE= lab.zaar.be/thefish/bearlibterminal v0.0.0-20191018101635-dd37bbc90d77/go.mod h1:tV7Vxx6vf9dPgj9B+RPeSrmtRl8nTSH07HIyBSSnEc4= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/prefab_test.go b/prefab_test.go new file mode 100644 index 0000000..99c883b --- /dev/null +++ b/prefab_test.go @@ -0,0 +1,17 @@ +package alchemyst_go + +import ( + "lab.zaar.be/thefish/alchemyst-go/engine/gamemap" + "testing" +) + +func TestPrefabLoad(t *testing.T) { + + testFile, err := gamemap.LoadPrefabFile("./assets/prefabs/test.json") + if err!= nil { + t.Log(err) + t.Fail() + } + t.Log(testFile) + +} diff --git a/ui/mainwindow/mainwindow.go b/ui/mainwindow/mainwindow.go index f23b75f..25daf6e 100644 --- a/ui/mainwindow/mainwindow.go +++ b/ui/mainwindow/mainwindow.go @@ -42,7 +42,7 @@ func (mw *MainWindow) Open() { //blt.Set("window: size=80x25, title="+config.Title+" v"+string(version)+"; font: ./fonts/Monaco-Linux.ttf, size=10") blt.Set( fmt.Sprintf( - //"window: size=%dx%d, title='%s v%s'; font: ./resources/fonts-bitmap/ibmnew8x12.png, size=8x12;", + //"window: size=%dx%d, title='%s v%s'; font: ./assets/fonts/bitmap/ibmnew8x12.png, size=8x12;", "window: size=%dx%d, title='%s %s'; font: %s, size=%s;", //"window: size=%dx%d, title='%s v%s'", config.MainWindowSizeX,