Eager load used sprites
This commit is contained in:
@@ -62,6 +62,21 @@ func (a *AssetStore) Map(name string) (*Map, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (m *Map) LoadSprites() error {
|
||||
// Eager load the sprites we use
|
||||
for x := m.Rect.Min.X; x <= m.Rect.Max.X; x++ {
|
||||
for y := m.Rect.Min.Y; y <= m.Rect.Max.Y; y++ {
|
||||
for z := 0; z < maps.MaxHeight; z++ {
|
||||
if _, err := m.SpritesForCell(x, y, z); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SpritesForCell returns the sprites needed to correctly render this cell.
|
||||
// They should be rendered from first to last to get the correct ordering
|
||||
func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error) {
|
||||
|
Reference in New Issue
Block a user