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:
2020-03-21 00:56:35 +00:00
parent eb5c4430e8
commit 7a8e9dbd97
10 changed files with 109 additions and 55 deletions

View File

@@ -11,8 +11,10 @@ import (
// * Width & height now stored using int
// * Colour data is now 32-bit rather than using a palette
type Sprite struct {
Width int
Height int
XOffset int
YOffset int
Width int
Height int
Image *ebiten.Image
}
@@ -39,14 +41,18 @@ func ConvertObject(rawObj *data.Object, name string) (*Object, error) {
}
for i, rawSpr := range rawObj.Sprites {
w := int(rawSpr.Width)
h := int(rawSpr.Height)
ebitenImage, err := ebiten.NewImageFromImage(rawSpr.ToImage(), ebiten.FilterDefault)
if err != nil {
return nil, err
}
out.Sprites[i] = &Sprite{Width: w, Height: h, Image: ebitenImage}
out.Sprites[i] = &Sprite{
XOffset: int(rawSpr.XOffset),
YOffset: int(rawSpr.YOffset),
Width: int(rawSpr.Width),
Height: int(rawSpr.Height),
Image: ebitenImage,
}
}
return out, nil