steel-lord/fov.go

25 lines
519 B
Go

package main
import (
"steel/mapping"
"github.com/kettek/goro/fov"
)
func InitializeFoV(g *mapping.GameMap) fov.Map {
fovMap := fov.NewMap(g.Width, g.Height, fov.AlgorithmBBQ)
for x := range g.Tiles {
for y, tile := range g.Tiles[x] {
fovMap.SetBlocksMovement(x, y, tile.BlockMovement)
fovMap.SetBlocksLight(x, y, tile.BlockSight)
}
}
return fovMap
}
func RecomputeFov(fovMap fov.Map, centerX, centerY int, radius int, fovLight fov.Light) {
fovMap.Recompute(centerX, centerY, radius, fovLight)
}