diff --git a/.gopath b/.gopath deleted file mode 100644 index e69de29..0000000 diff --git a/config.json b/config.json index ea1bcd6..0cadf1e 100644 --- a/config.json +++ b/config.json @@ -5,6 +5,6 @@ "sizeY": 47, "fpsLimit": 60, "font": "./resources/fonts-ttf/LiberationMono-Bold.ttf", - "fontSize": "8x12", + "fontSize": "9x14", "verbosity": "debug" -} \ 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 e55e498..4dec910 100644 --- a/engine/fov/precomputed_shade/precomputed_shade.go +++ b/engine/fov/precomputed_shade/precomputed_shade.go @@ -78,6 +78,9 @@ 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 = 1 +const MIN_WALL_LIT_TO_BE_VISIBLE = 4 + var errNotFoundCell = errors.New("Cell not found") var errOutOfBounds = errors.New("Cell out of bounds") @@ -163,9 +166,9 @@ func (ps *precomputedShade) PrecomputeFovMap() { //Bresanham lines / Raycast var lineX, lineY float64 - for i := 0; i < 360; i++ { - dx := math.Sin(float64(i) / (float64(180) / math.Pi)) - dy := math.Cos(float64(i) / (float64(180) / math.Pi)) + for i := 0; i < 720; i++ { // 1/2 of angles + dx := math.Sin(float64(i) / (float64(360) / math.Pi)) //1/2 of angles + dy := math.Cos(float64(i) / (float64(360) / math.Pi)) lineX = 0 lineY = 0 @@ -204,11 +207,11 @@ func (ps *precomputedShade) recalc(level *gamemap.Level, initCoords types.Coords level.GetTile(initCoords).Visible = true - var fullShade = make([]byte, 360) + var fullShade = make([]byte, 720) // 1/2 of angles for i := range fullShade { fullShade[i] = 1 } - var emptyShade = make([]byte, 360) + var emptyShade = make([]byte, 720) // 1/2 of angles currentShade := emptyShade nextShade := emptyShade @@ -236,7 +239,11 @@ func (ps *precomputedShade) recalc(level *gamemap.Level, initCoords types.Coords //fmt.Printf("\n level coords: %v", lc) for _, angle := range cell.occludedAngles { - if level.GetTile(lc).BlocksSight { + if level.GetTile(lc).BlocksSight && ps.LightWalls { + if (nextShade[angle] == 0 && currentShade[angle] == 0) { + level.GetTile(lc).Visible = true + level.GetTile(lc).Explored = true + } nextShade[angle] = 1 } @@ -256,7 +263,7 @@ 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 > 2 { + if cell.lit > MIN_LIT_TO_BE_VISIBLE { if err != nil { continue } @@ -265,21 +272,25 @@ func (ps *precomputedShade) ComputeFov(level *gamemap.Level, initCoords types.Co } //light walls, crutch - if level.GetTile(cs).BlocksSight && ps.LightWalls { - if cell.IsAdjacentTo(&types.Coords{0,0}) { - level.GetTile(cs).Visible = true - } else { - for _, maybeNb := range ps.CellList { - if //int(maybeNb.distance) == int(cell.distance-1) && - maybeNb.IsAdjacentTo(&cell.Coords) && - //(maybeNb.X == cell.X || maybeNb.Y == cell.Y) && - maybeNb.lit > 5 { //magic constant! - level.GetTile(cs).Visible = true - level.GetTile(cs).Explored = true - } - } - } - } + //if level.GetTile(cs).BlocksSight && ps.LightWalls { + // if cell.IsAdjacentTo(&types.Coords{0,0}) { + // level.GetTile(cs).Visible = true + // } else { + // maybeLit := false + // for _, maybeNb := range ps.CellList { + // if //int(maybeNb.distance) == int(cell.distance-1) && + // maybeNb.IsAdjacentTo(&cell.Coords) && + // (maybeNb.X == cell.X || maybeNb.Y == cell.Y) && + // maybeNb.lit > MIN_WALL_LIT_TO_BE_VISIBLE { //magic constant! + // maybeLit = true + // } + // } + // if maybeLit { + // level.GetTile(cs).Visible = true + // level.GetTile(cs).Explored = true + // } + // } + //} } }