You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
961 B
40 lines
961 B
//go:build example |
|
// +build example |
|
|
|
package system |
|
|
|
import ( |
|
"code.rocketnine.space/tslocum/gohan" |
|
"code.rocketnine.space/tslocum/gohan/examples/twinstick/asset" |
|
"code.rocketnine.space/tslocum/gohan/examples/twinstick/component" |
|
"github.com/hajimehoshi/ebiten/v2" |
|
) |
|
|
|
type drawPlayerSystem struct { |
|
player gohan.Entity |
|
op *ebiten.DrawImageOptions |
|
} |
|
|
|
func NewDrawPlayerSystem(player gohan.Entity) *drawPlayerSystem { |
|
return &drawPlayerSystem{ |
|
player: player, |
|
op: &ebiten.DrawImageOptions{}, |
|
} |
|
} |
|
|
|
func (s *drawPlayerSystem) Matches(entity gohan.Entity) bool { |
|
return entity == s.player |
|
} |
|
|
|
func (s *drawPlayerSystem) Update(_ gohan.Entity) error { |
|
return gohan.ErrSystemWithoutUpdate |
|
} |
|
|
|
func (s *drawPlayerSystem) Draw(entity gohan.Entity, screen *ebiten.Image) error { |
|
position := component.Position(entity) |
|
|
|
s.op.GeoM.Reset() |
|
s.op.GeoM.Translate(position.X-16, position.Y-16) |
|
screen.DrawImage(asset.ImgWhiteSquare, s.op) |
|
return nil |
|
}
|
|
|