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

41 lines
1.0 KiB

9 months ago
//go:build example
// +build example
package system
import (
type drawPlayerSystem struct {
player gohan.EntityID
op *ebiten.DrawImageOptions
func NewDrawPlayerSystem(player gohan.EntityID) *drawPlayerSystem {
return &drawPlayerSystem{
player: player,
op: &ebiten.DrawImageOptions{},
func (s *drawPlayerSystem) Matches(entity gohan.EntityID) bool {
return entity == s.player
func (s *drawPlayerSystem) Update(_ gohan.EntityID) error {
return gohan.ErrSystemWithoutUpdate
func (s *drawPlayerSystem) Draw(entity gohan.EntityID, screen *ebiten.Image) error {
position := entity.Component(component.PositionComponentID).(*component.PositionComponent)
s.op.GeoM.Translate(position.X-16, position.Y-16)
screen.DrawImage(asset.ImgWhiteSquare, s.op)
return nil