Respect sprite X and Y offsets
This makes menus display more correctly, and also fixes trees and other objects on the main map, although it messes up bounds clipping (sigh).
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"image"
|
||||
"log"
|
||||
|
||||
"github.com/hajimehoshi/ebiten"
|
||||
|
||||
"code.ur.gs/lupine/ordoor/internal/maps"
|
||||
)
|
||||
|
||||
@@ -64,11 +62,11 @@ func (a *AssetStore) Map(name string) (*Map, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// ImagesForCell returns the sprites needed to correctly render this cell.
|
||||
// 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) ImagesForCell(x, y, z int) ([]*ebiten.Image, error) {
|
||||
func (m *Map) SpritesForCell(x, y, z int) ([]*Sprite, error) {
|
||||
cell := m.raw.At(x, y, z)
|
||||
images := make([]*ebiten.Image, 0, 4)
|
||||
sprites := make([]*Sprite, 0, 4)
|
||||
|
||||
for _, ref := range []maps.ObjRef{cell.Surface, cell.Right, cell.Left, cell.Center} {
|
||||
if !ref.IsActive() {
|
||||
@@ -80,13 +78,13 @@ func (m *Map) ImagesForCell(x, y, z int) ([]*ebiten.Image, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
img, err := obj.Image(ref.Sprite())
|
||||
sprite, err := obj.Sprite(ref.Sprite())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
images = append(images, img)
|
||||
sprites = append(sprites, sprite)
|
||||
}
|
||||
|
||||
return images, nil
|
||||
return sprites, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user