From 284cdc5315a983aea9c8319938720b7f6e7ceb4f Mon Sep 17 00:00:00 2001 From: "anton.gurov" Date: Tue, 5 Nov 2019 12:43:06 +0300 Subject: [PATCH] merge changes --- cmd/game/main.go | 32 ++++++++++++++++++++++++---- engine/fov/basic/basic_raycasting.go | 2 ++ engine/gamemap/level.go | 1 + 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cmd/game/main.go b/cmd/game/main.go index 6fd4d9f..4f1435a 100644 --- a/cmd/game/main.go +++ b/cmd/game/main.go @@ -62,10 +62,34 @@ func main() { setupLayers(mw) - level := gamemap.NewLevel(mainCtx, "test", 1) - level = mapgens.DefaultGen(level) - vp := mainwindow.NewViewPort(40, 0, 60, 47, level, mw.GetLayer("base")) - vp.Render() + //fixme + level, rooms := mapgens.DefaultGen(gamemap.NewLevel(mainCtx, "test", 1)) + State.Level = level + vp := mainwindow.NewViewPort(30, 0, 70, 47, mw.GetLayer("base")) + + screenMgr := types.NewScreenManager(mainCtx) + screenMgr.AddScreen("title", &screens.TitleScreen{}) + screenMgr.AddScreen("game", screens.NewGameScreen(mw, &State, vp)) + + screenMgr.SetScreenByName("game") + + //fixme + //player := &mob.Player{ + // Mob: mob.Mob{ + // Appearance: &types.Appearance{ + // Glyph: &types.PlainGlyphHolder{"@"}, + // ColorSet: &types.TileColorSet{ + // Fg: &types.PlainColorHolder{255, 255, 255, 255}, + // }, + // }, + // Coords: rooms[0].Center, + // BlocksPass: true, + // }, + //} + //State.Player = player + + //vp.PlayerCoords = player.Coords + //vp.Render(&State) go decodeInput(mainCtx, mw.GetLayer("base")) go vp.Listen(State) diff --git a/engine/fov/basic/basic_raycasting.go b/engine/fov/basic/basic_raycasting.go index 05e0eb3..90e6de8 100644 --- a/engine/fov/basic/basic_raycasting.go +++ b/engine/fov/basic/basic_raycasting.go @@ -6,6 +6,8 @@ import ( "math" ) +//fixme store separate FovMap, add method IsInMap to it + type FieldOfVision struct { cosTable map[int]float64 sinTable map[int]float64 diff --git a/engine/gamemap/level.go b/engine/gamemap/level.go index c417dd6..89f4a6c 100644 --- a/engine/gamemap/level.go +++ b/engine/gamemap/level.go @@ -54,6 +54,7 @@ func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level { Depth: depth, Rect: types.NewRect(0,0, mapWidth, mapHeight), } + l.Tiles = make([]*Tile, l.W*l.H) ctx.Logger().Debug().Msgf("Generating level of branch %s depth %d", branch, depth) return l