33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package render
|
|
|
|
import (
|
|
"symph/game"
|
|
"symph/parameter"
|
|
)
|
|
|
|
// GridScan caches one frame of per-position lookahead and resolves the
|
|
// grid-wide nearest distances. Blink membership is a grid-scope property, so
|
|
// every position is scanned before any tile is drawn. Allocation-free: fixed
|
|
// arrays refilled in place, shared by both frontends
|
|
type GridScan struct {
|
|
Tiles [parameter.GamePlayIndexYMax][parameter.GamePlayIndexXMax]game.TileLookahead
|
|
NearPos int // grid-wide nearest positive distance; -1 when none
|
|
NearNeg int // grid-wide nearest negative distance; -1 when none
|
|
}
|
|
|
|
func (g *GridScan) Refresh(s *game.GameState) {
|
|
g.NearPos, g.NearNeg = -1, -1
|
|
for y := range parameter.GamePlayIndexYMax {
|
|
for x := range parameter.GamePlayIndexXMax {
|
|
tl := s.ScanTile(y, x, parameter.PositionLookaheadWindow)
|
|
g.Tiles[y][x] = tl
|
|
if d := tl.Positive.Distance; d >= 0 && (g.NearPos < 0 || d < g.NearPos) {
|
|
g.NearPos = d
|
|
}
|
|
if d := tl.Negative.Distance; d >= 0 && (g.NearNeg < 0 || d < g.NearNeg) {
|
|
g.NearNeg = d
|
|
}
|
|
}
|
|
}
|
|
}
|