Lazily load sprite image data
This cuts memory use significantly, since many sprites in an object are never used. We can get savings over time by evicting sprites when they go out of scope, but that's, well, out of scope. To achieve this, I introduce an assetstore package that is in charge of loading things from the filesystem. This also allows some lingering case-sensitivity issues to be handled cleanly. I'd hoped that creating fewer ebiten.Image instances would help CPU usage, but that doesn't seem to be the case.
This commit is contained in:
@@ -59,13 +59,17 @@ func (h Header) Height() int {
|
||||
return MaxHeight
|
||||
}
|
||||
|
||||
func (h Header) MapSetFilename() string {
|
||||
func (h Header) MapSetName() string {
|
||||
idx := bytes.IndexByte(h.SetName[:], 0)
|
||||
if idx < 0 {
|
||||
idx = 8 // all 8 bytes are used
|
||||
}
|
||||
|
||||
return string(h.SetName[0:idx:idx]) + ".set"
|
||||
return string(h.SetName[0:idx:idx])
|
||||
}
|
||||
|
||||
func (h Header) MapSetFilename() string {
|
||||
return h.MapSetName() + ".set"
|
||||
}
|
||||
|
||||
type ObjRef struct {
|
||||
|
Reference in New Issue
Block a user