rendering items, pick up, iventory re-make in progress to aloow item drop/wear/whatever

This commit is contained in:
2019-11-17 02:09:41 +03:00
parent 685dfeeeb1
commit 0a6c642dc2
12 changed files with 349 additions and 207 deletions

View File

@ -85,7 +85,7 @@ func main() {
//set up controller
controller := ecs.NewController()
controller := ecs.NewController(mainCtx)
controller.MapComponentClass(ecs.CoordsComponent, types.Coords{})
controller.MapComponentClass(ecs.AppearanceComponent, types.Appearance{})
@ -93,16 +93,21 @@ func main() {
controller.MapComponentClass(ecs.MoveableComponent, movement.Moveable{})
controller.MapComponentClass(ecs.CarriedComponent, movement.Moveable{})
controller.MapComponentClass(ecs.UsableComponent, movement.Moveable{})
controller.MapComponentClass(ecs.BackpackComponent, items.Backpack{})
moveable := movement.Moveable{
Controller: controller,
Level: level,
}
items.Init(controller)
bp := items.Backpack{MaxMass:100, MaxBulk:100}
//Set up Screen Manager
screenMgr := types.NewScreenManager(mainCtx)
screenMgr.AddScreen("title", screens.NewTitleScreen(mw, screenMgr))
screenMgr.AddScreen("game", screens.NewGameScreen(mw, &State, vp, controller, screenMgr))
screenMgr.AddScreen("game", screens.NewGameScreen(mainCtx, mw, &State, vp, controller, screenMgr))
screenMgr.AddScreen("help", screens.NewMenuScreen(
mw,
screenMgr,
@ -128,25 +133,20 @@ func main() {
}).MakeList(),
)
screenMgr.AddScreen("inventory", screens.NewMenuScreen(
mw,
screenMgr,
"Inventory",
"Items in your backpack:",
//"[color=yellow]Note[/color]: Many of these are not implemented yet",
"",
types.NewCenteredRect(mw.Rect, 70, 25),
true, ).
SetBgColor("#ef305c70").
SetFgColor("white").
SetItems([]interface{}{
`"Fish-eye" crafty shaded glasses`,
"Xecutor's glowing visor",
"Kitschy goggles of many pathways",
"Ring of inexistence",
"Orb of omniscience",
"Wand of amnesia",
}).MakeList(),
screenMgr.AddScreen("inventory", screens.InventoryScreen{
MenuScreen: screens.NewMenuScreen(
mw,
screenMgr,
"Inventory",
"Items in your backpack:",
//"[color=yellow]Note[/color]: Many of these are not implemented yet",
"",
types.NewCenteredRect(mw.Rect, 70, 25),
true, ).
SetBgColor("#ef305c70").
SetFgColor("white").
SetItems([]interface{}{}).MakeList()
},
)
screenMgr.AddScreen("devmenu", screens.NewDevmenuScreen(
@ -174,7 +174,9 @@ func main() {
controller.AddComponent(player, rooms[0].Center) //implicit Coords
controller.AddComponent(player, moveable)
controller.AddComponent(player, bp)
//fixme adding items
potion := controller.CreateEntity([]ecs.Component{})
controller.AddComponent(potion, types.Appearance{
Glyph: types.PlainGlyphHolder{"!"},
@ -182,11 +184,24 @@ func main() {
Fg: types.PlainColorHolder{255, 55, 255, 222},
},
})
controller.AddComponent(potion, rooms[1].Center) //implicit Coords
controller.AddComponent(potion, items.Carried{})
controller.AddComponent(potion, rooms[0].Center) //implicit Coords
controller.AddComponent(potion, items.Carried{Mass:5, Bulk:3})
controller.AddComponent(potion, items.Usable{})
controller.AddComponent(potion, items.Consumable{})
potion2 := controller.CreateEntity([]ecs.Component{})
controller.AddComponent(potion2, types.Appearance{
Glyph: types.PlainGlyphHolder{"!"},
ColorSet: types.TileColorSet{
Fg: types.PlainColorHolder{255, 222, 255, 55},
},
})
controller.AddComponent(potion2, rooms[1].Center) //implicit Coords
controller.AddComponent(potion2, items.Carried{Mass:5, Bulk:3})
controller.AddComponent(potion2, items.Usable{})
controller.AddComponent(potion2, items.Consumable{})
//fixme end setting up items
State.Player = player
State.Controller = controller