prefab changes

This commit is contained in:
anton.gurov 2019-11-13 10:58:30 +03:00
parent 6197e3be8e
commit 6353bd7ce3
4 changed files with 32 additions and 28 deletions

View File

@ -20,8 +20,8 @@ all: build test
build: distclean build.deps build.game
# build.game: build.game.linux64 build.game.win64 build.game.mac
build.game: build.game.linux64 build.game.win64
build.game: build.game.linux64 build.game.win64 build.game.mac
# build.game: build.game.linux64 build.game.win64
build.deps:
GIT_SSL_NO_VERIFY=true $(GO) mod vendor
@ -45,11 +45,14 @@ build.game.win64:
/usr/bin/x86_64-w64-mingw32-strip $(DISTFOLDER)/game.exe && \
cd $(DISTFOLDER) && zip -r ../$(PROJECT_NAME)-$(OS)-${PKG_VER}.zip . -x *.git*
# 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 &&
build.game.mac:
cp $(CWD)/lib/mac/libBearLibTerminal.dylib $(DISTFOLDER) && \
cp $(CWD)/config.json $(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 && \
OSXCROSS_NO_INCLUDE_PATH_WARNINGS=1 MACOSX_DEPLOYMENT_TARGET=10.6 CC=clang CXX=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*

View File

@ -1,5 +1,5 @@
{
"version": "v0.0.1.5-1-gbecf7ea",
"version": "v0.0.1.6",
"title": "Alchemyst",
"sizeX": 100,
"sizeY": 47,

View File

@ -30,7 +30,7 @@ type PrefabRecord struct {
func LoadPrefabFile(filename string) (*PrefabFile, error) {
data, err := ioutil.ReadFile(filename)
if err!= nil {
if err != nil {
return nil, err
}
instance := &PrefabFile{}
@ -53,7 +53,7 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
rooms := make([]Room, 0)
file, err := LoadPrefabFile("./assets/prefabs/test.json")
if err !=nil {
if err != nil {
panic(err)
}
@ -63,23 +63,23 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
currentMobsLegend := file.DefaultMobsLegend
currentItemLegend := file.DefaultItemLegend
for k,v := range rawPrefab.TileLegend {
for k, v := range rawPrefab.TileLegend {
currentTileLegend[k] = v
}
for k,v := range rawPrefab.MobsLegend {
for k, v := range rawPrefab.MobsLegend {
currentMobsLegend[k] = v
}
for k,v := range rawPrefab.ItemLegend {
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, 0),
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, 0),
}
//make geometry
var f func() *Tile
@ -89,7 +89,7 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
if len(str) != room.W {
continue;
}
for i:=0; i < room.W; i++ {
for i := 0; i < room.W; i++ {
ok := false
shortName := currentTileLegend[string(str[i])]
if shortName == "" {
@ -100,14 +100,15 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
}
if shortName == "connector" {
f = NewFloor
room.Connectors = append(room.Connectors, types.Coords{i,j})
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)
}
}
if (!ok) {
pfbl.ctx.Logger().Warn().Msgf("Unknown tile: %s", shortName)
}
room.Geometry[i+ j*room.W] = f
room.Geometry[i+j*room.W] = f
}
}
//add room to list
@ -116,10 +117,10 @@ func (pfbl PrefabLoader) PrefabRoomsList() []Room {
return rooms
}
var TileTypeMap = map[string]func()*Tile{
"wall": NewWall,
"floor": NewFloor,
var TileTypeMap = map[string]func() *Tile{
"wall": NewWall,
"floor": NewFloor,
"decorated_wall": NewDecoratedWall,
"water": NewWaterTile,
"deep_water": NewDeepWaterTile,
}
"water": NewWaterTile,
"deep_water": NewDeepWaterTile,
}

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.12
require (
github.com/gammazero/deque v0.0.0-20190521012701-46e4ffb7a622
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
github.com/rs/zerolog v1.15.0
lab.zaar.be/thefish/bearlibterminal v0.0.0-20191018101635-dd37bbc90d77
)