...

Package world

Overview ▾

Index ▾

Package files

logic.go node.go scene.go sprite.go

type HandlesHover

type HandlesHover interface {
    Hover(x float64, y float64) bool
}

type HandlesMouseDown

type HandlesMouseDown interface {
    MouseDown(x float64, y float64, button ebiten.MouseButton) bool
}

type HandlesMouseUp

type HandlesMouseUp interface {
    MouseUp(x float64, y float64, button ebiten.MouseButton) bool
}

type Logic

Logic is an invisible node.

type Logic struct {
    UpdateFunc func(screen *ebiten.Image) error

    sync.Mutex
    // contains filtered or unexported fields
}

func NewLogic

func NewLogic(updateFunc func(screen *ebiten.Image) error) *Logic

NewLogic returns a new Logic node.

func (*Logic) AddNode

func (l *Logic) AddNode(node Node)

AddNode adds a node.

func (*Logic) Draw

func (l *Logic) Draw(screen *ebiten.Image)

Draw does nothing.

func (*Logic) Hit

func (l *Logic) Hit(x float64, y float64) bool

func (*Logic) HitTest

func (l *Logic) HitTest(x float64, y float64) bool

func (*Logic) Nodes

func (l *Logic) Nodes() []Node

Nodes returns any contained nodes.

func (*Logic) Update

func (l *Logic) Update(screen *ebiten.Image) error

Update calls UpdateFunc.

type Node

Node is an object.

type Node interface {
    AddNode(Node)
    HitTest(x float64, y float64) bool
    Nodes() []Node
    Update(screen *ebiten.Image) error
    Draw(screen *ebiten.Image)
}

type Scene

Scene is a node which organizes nodes.

type Scene struct {
    *Logic
}

func NewScene

func NewScene(updateFunc func(screen *ebiten.Image) error) *Scene

NewScene returns a new Scene.

func (*Scene) Clear

func (n *Scene) Clear()

Clear removes all nodes from a scene.

func (*Scene) RemoveNode

func (n *Scene) RemoveNode(node Node)

RemoveNode removes the provided node from a scene.

func (*Scene) SetNode

func (n *Scene) SetNode(node Node)

SetNode sets the nodes of a scene.

func (*Scene) SetNodes

func (n *Scene) SetNodes(nodes []Node)

SetNodes sets the nodes of a scene.

type Sprite

Sprite is a graphical node.

type Sprite struct {
    *Logic
    Image  *ebiten.Image
    Images []*ebiten.Image

    Visible bool
    // contains filtered or unexported fields
}

func NewSprite

func NewSprite(image *ebiten.Image, updateFunc func(screen *ebiten.Image) error) *Sprite

NewSprite returns a new Sprite node.

func (*Sprite) AddPosition

func (s *Sprite) AddPosition(x float64, y float64)

AddPosition adds to the position of the node.

func (*Sprite) Draw

func (s *Sprite) Draw(screen *ebiten.Image)

Draw draws the node.

func (*Sprite) GetColorM

func (s *Sprite) GetColorM() *ebiten.ColorM

func (*Sprite) GetPosition

func (s *Sprite) GetPosition() (x float64, y float64)

GetPosition returns the position of the node.

func (*Sprite) GetScale

func (s *Sprite) GetScale() (float64, float64)

SetPosition sets the position of the node.

func (*Sprite) GetSize

func (s *Sprite) GetSize() (float64, float64)

func (*Sprite) HitExact

func (s *Sprite) HitExact(x float64, y float64) bool

HitExact returns whether the the specified position is within a non-transparent area of the sprite.

func (*Sprite) HitTest

func (s *Sprite) HitTest(x float64, y float64) bool

HitTest returns whether the the specified position is within the sprite bounds.

func (*Sprite) SetColorM

func (s *Sprite) SetColorM(colorm *ebiten.ColorM)

func (*Sprite) SetImage

func (s *Sprite) SetImage(image *ebiten.Image)

SetPosition sets the position of the node.

func (*Sprite) SetPosition

func (s *Sprite) SetPosition(x float64, y float64)

SetPosition sets the position of the node.

func (*Sprite) SetScale

func (s *Sprite) SetScale(x float64, y float64)

SetPosition sets the position of the node.