use gogues ecs, not working, needs rethinking
This commit is contained in:
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/ecs"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamemap/mapgens"
|
||||
"lab.zaar.be/thefish/alchemyst-go/engine/gamestate"
|
||||
@ -44,8 +45,8 @@ var State = gamestate.GameState{
|
||||
Exit: make(chan struct{}, 1),
|
||||
Input: make(chan string, 1),
|
||||
RawInput: make(chan int, 1),
|
||||
FovRecompute: make(chan struct{},1),
|
||||
Redraw: make(chan struct{},1),
|
||||
FovRecompute: make(chan struct{}, 1),
|
||||
Redraw: make(chan struct{}, 1),
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -66,35 +67,58 @@ func main() {
|
||||
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
|
||||
//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)
|
||||
//vp.PlayerCoords = player.Coords
|
||||
//vp.Render(&State)
|
||||
|
||||
go decodeInput(mainCtx, mw.GetLayer("base"))
|
||||
go vp.Listen(State)
|
||||
|
||||
controller := ecs.NewController()
|
||||
|
||||
controller.MapComponentClass("coords", types.Coords{})
|
||||
controller.MapComponentClass("appearance", types.Appearance{})
|
||||
controller.MapComponentClass("mob", mob.Mob{})
|
||||
|
||||
player := controller.CreateEntity([]ecs.Component{})
|
||||
|
||||
controller.AddComponent(player, &types.Appearance{
|
||||
Glyph: &types.PlainGlyphHolder{"@"},
|
||||
ColorSet: &types.TileColorSet{
|
||||
Fg: &types.PlainColorHolder{255, 255, 255, 255},
|
||||
},
|
||||
})
|
||||
|
||||
controller.AddComponent(player, rooms[0].Center) //implicit Coords
|
||||
|
||||
|
||||
render := mob.MobRenderSystem{EntityController: controller}
|
||||
|
||||
controller.AddSystem(render, 1)
|
||||
|
||||
|
||||
|
||||
|
||||
//but every call to bearlibterminal must be wrapped to closure and passed to mainfunc
|
||||
var exit = false
|
||||
for !exit {
|
||||
@ -112,7 +136,7 @@ func main() {
|
||||
mainCtx.Logger().Warn().Msg("quitting NOW")
|
||||
exit = true
|
||||
break
|
||||
// не оставляйте default в бесконесчном select {} - сожрет всё CPU
|
||||
// не оставляйте default в бесконесчном select {} - сожрет всё CPU
|
||||
default:
|
||||
screenMgr.CurrentScreen.Render()
|
||||
blt.Refresh()
|
||||
|
Reference in New Issue
Block a user