fix supid viewport bug

This commit is contained in:
2019-11-01 19:59:12 +03:00
parent 529f5a5749
commit 17ef52a5cf
5 changed files with 29 additions and 14 deletions

View File

@ -195,7 +195,9 @@ func (ps *precomputedShade) PrecomputeFovMap() {
}
func (ps *precomputedShade) recalc(level *gamemap.Level, initCoords types.Coords, radius int) {
for i, _ := range ps.CellList {
ps.CellList[i].lit = 0
}
ps.originCoords = initCoords
if radius > ps.MaxTorchRadius {
@ -250,6 +252,7 @@ func (ps *precomputedShade) recalc(level *gamemap.Level, initCoords types.Coords
func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Coords, radius int) {
level.SetAllInvisible()
ps.recalc(level, initCoords, radius)
for _, cell := range ps.CellList {
@ -260,6 +263,7 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co
continue
}
level.GetTile(cs).Visible = true
level.GetTile(cs).Explored = true
}
//light walls, crutch
@ -273,6 +277,7 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co
(maybeNb.X == cell.X || maybeNb.Y == cell.Y) &&
maybeNb.lit > 0 { //magic constant!
level.GetTile(cs).Visible = true
level.GetTile(cs).Explored = true
}
}
}

View File

@ -58,6 +58,12 @@ func NewLevel(ctx util.ClientCtx, branch string, depth int) *Level {
return l
}
func (l *Level) SetAllInvisible() {
for idx, _ := range l.Tiles {
l.Tiles[idx].Visible = false
}
}
type Room struct {
*types.Rect
Center types.Coords

View File

@ -1,6 +1,9 @@
package mob
import "lab.zaar.be/thefish/alchemyst-go/engine/types"
import (
"fmt"
"lab.zaar.be/thefish/alchemyst-go/engine/types"
)
type Mob struct {
*types.Appearance
@ -9,7 +12,8 @@ type Mob struct {
}
func (m *Mob) Walk(dx, dy int) {
m.Coords = types.Coords{m.X + dx, m.Y + dy}
fmt.Printf("new coords: %d, %d\n", m.Coords.X, m.Coords.Y)
}
func (m *Mob) Render() {

View File

@ -42,7 +42,7 @@ func (ts *GameScreen) HandleInput(input string) {
ts.state.Player.Walk(-1, 1)
break
case "n", "3":
ts.state.Player.Walk(-1, 3)
ts.state.Player.Walk(1, 1)
break
default:
ts.mw.GetLayer("base").ClearArea(0, 3, 40, 1)