2019-07-17 01:30:15 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-07-19 21:08:46 -07:00
|
|
|
"steel/interfaces"
|
2019-07-17 18:37:24 -07:00
|
|
|
|
2019-07-17 01:30:15 -07:00
|
|
|
"github.com/kettek/goro/fov"
|
|
|
|
)
|
|
|
|
|
2019-07-19 21:08:46 -07:00
|
|
|
func InitializeFoV(g interfaces.GameMap) fov.Map {
|
|
|
|
fovMap := fov.NewMap(g.Width(), g.Height(), fov.AlgorithmBBQ)
|
2019-07-17 01:30:15 -07:00
|
|
|
|
2019-07-19 21:08:46 -07:00
|
|
|
for x := 0; x < g.Width(); x++ {
|
|
|
|
for y := 0; y < g.Height(); y++ {
|
|
|
|
fovMap.SetBlocksMovement(x, y, g.IsBlocked(x, y))
|
|
|
|
fovMap.SetBlocksLight(x, y, g.IsOpaque(x, y))
|
2019-07-17 01:30:15 -07:00
|
|
|
}
|
|
|
|
}
|
2019-07-17 18:37:24 -07:00
|
|
|
|
2019-07-17 01:30:15 -07:00
|
|
|
return fovMap
|
|
|
|
}
|
|
|
|
|
2019-07-17 18:37:24 -07:00
|
|
|
func RecomputeFov(fovMap fov.Map, centerX, centerY int, radius int, fovLight fov.Light) {
|
|
|
|
fovMap.Recompute(centerX, centerY, radius, fovLight)
|
2019-07-17 01:30:15 -07:00
|
|
|
}
|