diff --git a/assets/prefabs/test.json b/assets/prefabs/test.json index 1cd3238..eeb0170 100644 --- a/assets/prefabs/test.json +++ b/assets/prefabs/test.json @@ -9,6 +9,29 @@ "default_item_legend": {}, "prefabs": [ + {"name": "test_room_3", + "size":{"x":20, "y":17}, + "body": [ + "##########+#########", + "#..................#", + "#..................#", + "#..................#", + "#..................#", + "#..................#", + "#........#.........#", + "#.....#............#", + "#...#.....#........#", + "+.....#..#.........+", + "#......#...........#", + "#..................#", + "#..................#", + "#..................#", + "#..................#", + "#..................#", + "#..................#", + "##########+#########" + ] + }, {"name": "test_room_2", "tile_legend": { "D": "decorated_wall" @@ -56,30 +79,6 @@ "???DDDD#.#DDDD??", "???????#+#??????" ] - - }, - {"name": "test_room_3", - "size":{"x":20, "y":17}, - "body": [ - "##########+#########", - "#..................#", - "#..................#", - "#..................#", - "#..................#", - "#..................#", - "#........#.........#", - "#.....#............#", - "#...#.....#........#", - "+.....#..#.........+", - "#......#...........#", - "#..................#", - "#..................#", - "#..................#", - "#..................#", - "#..................#", - "#..................#", - "##########+#########" - ] } ] } diff --git a/cmd/game/main.go b/cmd/game/main.go index ff7f7c9..2fc4b78 100644 --- a/cmd/game/main.go +++ b/cmd/game/main.go @@ -150,6 +150,7 @@ func main() { screenMgr.AddScreen("devmenu", screens.NewDevmenuScreen( mw, + controller, screenMgr, &State, types.NewCenteredRect(mw.Rect, 70, 25), diff --git a/effects/buffs.go b/effects/buffs.go new file mode 100644 index 0000000..02ab254 --- /dev/null +++ b/effects/buffs.go @@ -0,0 +1,9 @@ +package effects + +const BuffPassWall = "pass_wall" + +type PassWall struct {} + +func (PassWall) Type() string { + return BuffPassWall +} \ No newline at end of file diff --git a/engine/fov/precomputed_shade/precomputed_shade.go b/engine/fov/precomputed_shade/precomputed_shade.go index 3fa9af2..9c51fca 100644 --- a/engine/fov/precomputed_shade/precomputed_shade.go +++ b/engine/fov/precomputed_shade/precomputed_shade.go @@ -78,7 +78,7 @@ Pre-Computed Visiblity Trees on RogueBasin Adam Milazzo's FOV Method Roundup where a similar method described as 'permissive' is detailed */ -const MIN_LIT_TO_BE_VISIBLE = 0 +const MIN_LIT_TO_BE_VISIBLE = 3 const MIN_WALL_LIT_TO_BE_VISIBLE = 4 var errNotFoundCell = errors.New("Cell not found") @@ -264,8 +264,8 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co for _, cell := range ps.CellList { //fmt.Printf("\n coords: %v, distance: %f, lit: %d", cell.Coords, cell.distance, cell.lit) cs, err := ps.toLevelCoords(level, initCoords, cell.Coords) - //if cell.lit > 0 && cell.lit > MIN_LIT_TO_BE_VISIBLE { - if cell.lit > 0 && cell.lit / (ps.MaxTorchRadius - int(cell.distance -1)) > MIN_LIT_TO_BE_VISIBLE { + if cell.lit > 0 && cell.lit > MIN_LIT_TO_BE_VISIBLE { + //if cell.lit > 0 && cell.lit / (ps.MaxTorchRadius - int(cell.distance - 0.4) - 1) > MIN_LIT_TO_BE_VISIBLE { if err != nil { continue } diff --git a/engine/gamemap/tile.go b/engine/gamemap/tile.go index 6a910f5..0654985 100644 --- a/engine/gamemap/tile.go +++ b/engine/gamemap/tile.go @@ -39,7 +39,7 @@ func NewWall() *Tile { return &Tile{ Name: "Wall", Description: "A dull rock wall", - BlocksPass: false, + BlocksPass: true, BlocksSight: true, Explored: false, MustDraw: false, @@ -57,8 +57,8 @@ func NewWall() *Tile { func NewDecoratedWall() *Tile { return &Tile{ - Name: "Wall", - Description: "A dull rock wall", + Name: "Decorated Wall", + Description: "A rock wall covered with paintings", BlocksPass: true, BlocksSight: true, Explored: false, diff --git a/engine/mob/movement/movement.go b/engine/mob/movement/movement.go index 67d408d..a383a92 100644 --- a/engine/mob/movement/movement.go +++ b/engine/mob/movement/movement.go @@ -3,6 +3,7 @@ package movement import ( "lab.zaar.be/thefish/alchemyst-go/engine/ecs" "lab.zaar.be/thefish/alchemyst-go/engine/gamemap" + "lab.zaar.be/thefish/alchemyst-go/engine/gamestate" "lab.zaar.be/thefish/alchemyst-go/engine/mob" "lab.zaar.be/thefish/alchemyst-go/engine/types" ) @@ -45,3 +46,23 @@ func (mov Moveable) IsBlocked(c types.Coords) bool { } return false } + +func Walk(entity ecs.Entity, state *gamestate.GameState, dx, dy int) { + controller := state.Controller + coords := controller.GetComponent(state.Player, ecs.CoordsComponent).(types.Coords) + newCoords := types.Coords{coords.X + dx, coords.Y + dy} + if !state.Level.InBounds(newCoords) { + return + } + movable := controller.GetComponent(entity, ecs.MoveableComponent) + if movable == nil { + return + } + if !movable.(Moveable).IsBlocked(newCoords) || + controller.GetComponent(entity, "pass_wall") != nil { + controller.UpdateComponent(state.Player, ecs.CoordsComponent, newCoords) + } + + state.Redraw <- struct{}{} + state.FovRecompute <- struct{}{} +} diff --git a/engine/screens/devmenu.go b/engine/screens/devmenu.go index 98cdd8b..fcb24f7 100644 --- a/engine/screens/devmenu.go +++ b/engine/screens/devmenu.go @@ -2,6 +2,8 @@ package screens import ( "fmt" + "lab.zaar.be/thefish/alchemyst-go/effects" + "lab.zaar.be/thefish/alchemyst-go/engine/ecs" "lab.zaar.be/thefish/alchemyst-go/engine/gamestate" "lab.zaar.be/thefish/alchemyst-go/engine/types" "lab.zaar.be/thefish/alchemyst-go/ui/mainwindow" @@ -9,23 +11,24 @@ import ( ) type DevmenuScreen struct { - mw *mainwindow.MainWindow - scm *types.ScreenManager - state *gamestate.GameState - + mw *mainwindow.MainWindow + controller *ecs.Controller + scm *types.ScreenManager + state *gamestate.GameState types.Rect renderParent bool - bgColor string - fgColor string + bgColor string + fgColor string } -func NewDevmenuScreen(mw *mainwindow.MainWindow, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen { +func NewDevmenuScreen(mw *mainwindow.MainWindow, controller *ecs.Controller, scm *types.ScreenManager, state *gamestate.GameState, rect types.Rect, renderParent bool) *DevmenuScreen { return &DevmenuScreen{ - mw: mw, - scm: scm, - state: state, + mw: mw, + controller: controller, + scm: scm, + state: state, Rect: rect, renderParent: renderParent, @@ -65,6 +68,12 @@ func (devm *DevmenuScreen) HandleInput(input string) { fmt.Printf("making everything visible!") devm.scm.SetScreen(devm.scm.PreviousScreen) break + case "p": + if devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall) { + devm.controller.RemoveComponent(devm.state.Player, effects.BuffPassWall) + } else { + devm.controller.AddComponent(devm.state.Player, effects.PassWall{}) + } case "Escape": fallthrough case "Space": @@ -72,7 +81,7 @@ func (devm *DevmenuScreen) HandleInput(input string) { break } } -func (devm *DevmenuScreen) Exit() { +func (devm *DevmenuScreen) Exit() { if devm.renderParent { devm.scm.PreviousScreen.Render() } @@ -95,10 +104,12 @@ func (devm *DevmenuScreen) Render() { "Dev Menu:", "[color=green]v[/color] - set all tiles visible", "[color=green]i[/color] - set all tiles invisible", + fmt.Sprintf("[color=green]p[/color] - toggle passwall: %v", + devm.controller.HasComponent(devm.state.Player, effects.BuffPassWall), + ), }, "\n"), 1, ) menuLayer.Print(devm.X+2, devm.Y+devm.H-1, "[color=green]Space[/color] to close") - -} \ No newline at end of file +} diff --git a/engine/screens/game.go b/engine/screens/game.go index 38953a2..f3b970a 100644 --- a/engine/screens/game.go +++ b/engine/screens/game.go @@ -39,28 +39,28 @@ func (ts *GameScreen) HandleInput(input string) { //ts.state.Do(func(){ switch input { case "Up", "k", "KP_8": - ts.walk(ts.state, 0, -1) + movement.Walk(ts.state.Player, ts.state, 0, -1) break case "Down", "j", "KP_2": - ts.walk(ts.state, 0, 1) + movement.Walk(ts.state.Player, ts.state, 0, 1) break case "Left", "h", "KP_4": - ts.walk(ts.state, -1, 0) + movement.Walk(ts.state.Player, ts.state, -1, 0) break case "Right", "l", "KP_6": - ts.walk(ts.state, 1, 0) + movement.Walk(ts.state.Player, ts.state, 1, 0) break case "y", "KP_7": - ts.walk(ts.state, -1, -1) + movement.Walk(ts.state.Player, ts.state, -1, -1) break case "u", "KP_9": - ts.walk(ts.state, 1, -1) + movement.Walk(ts.state.Player, ts.state, 1, -1) break case "b", "KP_1": - ts.walk(ts.state, -1, 1) + movement.Walk(ts.state.Player, ts.state, -1, 1) break case "n", "KP_3": - ts.walk(ts.state, 1, 1) + movement.Walk(ts.state.Player, ts.state, 1, 1) break case "Shift+/": ts.scm.SetScreenByName("help") @@ -76,7 +76,6 @@ func (ts *GameScreen) HandleInput(input string) { ts.mw.GetLayer("base").ClearArea(0, 3, 40, 1) ts.mw.GetLayer("base").Print(1, 3, "Key: "+input) ts.mw.GetLayer("base").Print(1, 6, "█") - } //}) } @@ -85,16 +84,4 @@ func (ts *GameScreen) Render() { ts.vp.Render(ts.state) } -func (ts *GameScreen) walk(state *gamestate.GameState, dx, dy int) { - controller := state.Controller - coords := controller.GetComponent(state.Player, ecs.CoordsComponent).(types.Coords) - newCoords := types.Coords{coords.X + dx, coords.Y + dy} - movable := controller.GetComponent(state.Player, ecs.MoveableComponent).(movement.Moveable) - if !movable.IsBlocked(newCoords) { - controller.UpdateComponent(state.Player, ecs.CoordsComponent, newCoords) - } - - state.Redraw <- struct{}{} - state.FovRecompute <- struct{}{} -} diff --git a/engine/screens/title.go b/engine/screens/title.go index 619bc02..693c2cc 100644 --- a/engine/screens/title.go +++ b/engine/screens/title.go @@ -35,22 +35,12 @@ func (ts *TitleScreen) Render() { } var logo = ` - .ddxo. .c c xlx - .kd. .0o:O, c0uO' - xc 0; x: ko ,, - ;l Y; c, .Yct; - .. .. ....... - :o: :k; .cxloOo x0. kO .olldk; do .;k lO. dO 'xllxk; ocokk:dl - .lKO, .kl 'dl c l0l..;dK lkx..;d: dOx .cOx ,0o c0 kk. .Y .Oo - .l0.k0. .0l lK. l0oxxxOK OK;xxx kKOklOkx ,kO;'do. ;xO: .Oo - :OoooxO .Ol ;Xc , cK' dK xX. , Ox YY xx ,O0. . .oKx. .0o -;k. .Ox Ok..'.,l ;Kk:;dk cKl lX: dKc,;oc kx kk OO dKl;lk: .0O -l; ,o .kK0KKK; :Ok; c; l: .oxc. x: Ol xl .dk: .o + Precomputed shade test ` var menu = ` -Alchemyst (c) 2011-2014 thefish +(c) 2019 thefish