v0.1.0 initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user