gg/src/gx/sprite.go

39 lines
450 B
Go
Raw Normal View History

2023-02-17 12:47:17 +03:00
package gx
2023-02-17 23:51:40 +03:00
import (
"github.com/hajimehoshi/ebiten/v2"
)
type Sprite struct {
I *Image
T Transform
2023-05-22 23:39:01 +03:00
S *Shader
2023-02-18 03:51:43 +03:00
Floating bool
}
2023-02-17 23:51:40 +03:00
func (s *Sprite) Draw(
e *Engine,
i *Image,
) {
2023-05-22 23:39:01 +03:00
op := &ebiten.DrawImageOptions{
}
2023-02-18 19:35:38 +03:00
m := &Matrix{}
2023-02-17 23:51:40 +03:00
m.Concat(s.T.Matrix(e))
2023-02-18 03:51:43 +03:00
if e.camera != nil {
m.Concat(e.camera.RealMatrix(
e,
true,
))
2023-02-18 03:51:43 +03:00
}
2023-02-18 19:35:38 +03:00
op.GeoM = *m
2023-05-22 23:39:01 +03:00
/*if s.S != nil {
bufImg := ebiten.NewImageFromImage(s.I)
} */
i.DrawImage(s.I, op)
2023-02-17 23:51:40 +03:00
}