Entity Component System framework for Ebiten
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.

43 lines
1.0 KiB

//go:build example
// +build example
package system
import (
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) Components() []gohan.ComponentID {
return []gohan.ComponentID{
func (s *drawPlayerSystem) Update(_ *gohan.Context) error {
return gohan.ErrSystemWithoutUpdate
func (s *drawPlayerSystem) Draw(ctx *gohan.Context, screen *ebiten.Image) error {
position := component.Position(ctx)
s.op.GeoM.Translate(position.X-16, position.Y-16)
screen.DrawImage(asset.ImgWhiteSquare, s.op)
return nil