flat

package
v0.0.0-...-04212e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Content embed.FS
View Source
var StopIterating = errors.New("stop iterating actors")

Functions

func ApplyComponentTransforms

func ApplyComponentTransforms(tr Transformer, geom *ebiten.GeoM)

Apply all the transforms up the owning chain so that nested components can have relative transforms

func ApplyTransform

func ApplyTransform(transform *Transform, geom *ebiten.GeoM)

func Assert

func Assert(expr bool, message string)

func Check

func Check(e error)

Check will panic if e is not nil, with e being passed to panic

func Clamp

func Clamp[T constraints.Float | constraints.Integer](current, min, max T) T

func CodeBlock

func CodeBlock[T any](name string, description string, factory func() *T)

func DegToRad

func DegToRad(deg float64) float64

func Errorf

func Errorf(format string, args ...any) error

Errorf is just like fmt.Errorf, but appends a stack trace to the output

func FindActorsByType

func FindActorsByType[T Actor](world *World) []T

func FindComponentsByType

func FindComponentsByType[T Component](parent Component) []T

func ForEachActorByType

func ForEachActorByType[T Actor](world *World, callback func(actor T) error)

func FrameTime

func FrameTime() float64

func RegisterAllFlatTypes

func RegisterAllFlatTypes()

func SliceToSet

func SliceToSet[T comparable](s []T) map[T]struct{}

func TypeOf

func TypeOf[T any]() reflect.Type

func WalkComponents

func WalkComponents(c Component, callback func(target, parent Component))

func WalkUpComponentOwners

func WalkUpComponentOwners(start Component, callback func(comp Component))

Types

type Actor

type Actor interface {
	Transformer
	Component
	Playable
	IsActor()
}

type ActorBase

type ActorBase struct {
	Transform  Transform
	Components []Component `flat:"inline"`
	// contains filtered or unexported fields
}

func (*ActorBase) BeginPlay

func (a *ActorBase) BeginPlay(rootParent Actor)

BeginPlay must be called

func (*ActorBase) Draw

func (a *ActorBase) Draw(screen *ebiten.Image)

func (*ActorBase) GetComponents

func (a *ActorBase) GetComponents() []Component

func (*ActorBase) GetTransform

func (a *ActorBase) GetTransform() *Transform

func (*ActorBase) IsActor

func (a *ActorBase) IsActor()

func (*ActorBase) Owner

func (a *ActorBase) Owner() Component

func (*ActorBase) SetComponents

func (a *ActorBase) SetComponents(comps []Component)

func (*ActorBase) SetOwner

func (a *ActorBase) SetOwner(o Component)

func (*ActorBase) Update

func (a *ActorBase) Update()

type Bounder

type Bounder interface {
	Bounds() image.Rectangle
}

type Component

type Component interface {
	Transformer
	SetComponents([]Component)
	GetComponents() []Component
	SetOwner(owner Component)
	Owner() Component
}

Component

type ComponentBase

type ComponentBase struct {
	Transform Transform

	Children []Component `flat:"inline"`
	// contains filtered or unexported fields
}

func (*ComponentBase) GetComponents

func (c *ComponentBase) GetComponents() []Component

func (*ComponentBase) GetTransform

func (c *ComponentBase) GetTransform() *Transform

func (*ComponentBase) Owner

func (c *ComponentBase) Owner() Component

func (*ComponentBase) SetComponents

func (c *ComponentBase) SetComponents(comps []Component)

func (*ComponentBase) SetOwner

func (c *ComponentBase) SetOwner(owner Component)

type Drawable

type Drawable interface {
	Draw(screen *ebiten.Image)
}

type EditorPlayable

type EditorPlayable interface {
	EditorBeginPlay()
}

EditorPlayable will be called by the editor instead of Begin play in certain editor situations

type EmptyActor

type EmptyActor struct {
	ActorBase
}

EmptyActor can be used when you need an actor that is entirely defined by its components

func (*EmptyActor) BeginPlay

func (a *EmptyActor) BeginPlay()

type Font

type Font struct {
	Name    string
	TtfFile asset.Path `flat:"filter:ttf"`
	Options opentype.FaceOptions
	// contains filtered or unexported fields
}

func (*Font) DefaultInitialize

func (f *Font) DefaultInitialize()

func (*Font) Face

func (f *Font) Face() font.Face

func (*Font) PostLoad

func (f *Font) PostLoad()

type Image

type Image struct {
	Path asset.Path `filter:"png"`
	// contains filtered or unexported fields
}

func (*Image) GetImage

func (i *Image) GetImage() *ebiten.Image

func (*Image) PostLoad

func (i *Image) PostLoad()

func (*Image) Reset

func (i *Image) Reset()

type ImageComponent

type ImageComponent struct {
	ComponentBase
	Image *Image
	// contains filtered or unexported fields
}

func (*ImageComponent) BeginPlay

func (c *ImageComponent) BeginPlay()

func (*ImageComponent) Bounds

func (c *ImageComponent) Bounds() image.Rectangle

func (*ImageComponent) Draw

func (c *ImageComponent) Draw(screen *ebiten.Image)

func (*ImageComponent) String

func (c *ImageComponent) String() string

type MouseEvent

type MouseEvent interface {
	OnEnter(owner Actor)
	OnExit(owner Actor)
	OnMouseButton(owner Actor, button ebiten.MouseButton)
}

type MouseEventComponent

type MouseEventComponent struct {
	ComponentBase

	EventHandler MouseEvent `flat:"inline"`
}

func (*MouseEventComponent) BeginPlay

func (m *MouseEventComponent) BeginPlay()

type Playable

type Playable interface {
	BeginPlay()
}

Playable will be called right before a world is ready to run and start ticking

type PositionAnchor

type PositionAnchor int
const (
	UpperLeft PositionAnchor = iota
	UpperCenter
	UpperRight
	CenterLeft
	CenterCenter
	CenterRight
	LowerLeft
	LowerCenter
	LowerRight
)

type ScreenPositionComponent

type ScreenPositionComponent struct {
	ComponentBase
	Anchor                 PositionAnchor
	XPercentAwayFromAnchor float32
	YPercentAwayFromAnchor float32
	XPixelsAwayFromAnchor  int32
	YPixelsAwayFromAnchor  int32
}

func (*ScreenPositionComponent) Draw

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

type TestMouseHandler

type TestMouseHandler struct {
	ToPrint string
}

func (TestMouseHandler) OnEnter

func (t TestMouseHandler) OnEnter(owner Actor)

func (TestMouseHandler) OnExit

func (t TestMouseHandler) OnExit(owner Actor)

func (TestMouseHandler) OnMouseButton

func (t TestMouseHandler) OnMouseButton(owner Actor, button ebiten.MouseButton)

type TextComponent

type TextComponent struct {
	ComponentBase
	Font                  *Font
	Color                 color.RGBA
	Name                  string
	TextTemplate          string
	IgnoreParentRotations bool
	// contains filtered or unexported fields
}

func (*TextComponent) Draw

func (t *TextComponent) Draw(screen *ebiten.Image)

func (*TextComponent) SetValues

func (t *TextComponent) SetValues(data any)

type Transform

type Transform struct {
	Location vector3.Vector3
	Rotation float64
	ScaleX   float64
	ScaleY   float64
}

func (*Transform) Add

func (t *Transform) Add(v vector3.Vector3)

func (*Transform) AddRotation

func (t *Transform) AddRotation(deg float64)

func (*Transform) DefaultInitialize

func (t *Transform) DefaultInitialize()

type Transformer

type Transformer interface {
	GetTransform() *Transform
}

type Updateable

type Updateable interface {
	Update()
}

type World

type World struct {
	PersistentActors []Actor `flat:"inline"`
	// contains filtered or unexported fields
}

func NewWorld

func NewWorld() *World

func (*World) AddToWorld

func (w *World) AddToWorld(actor Actor)

func (*World) BeginPlay

func (w *World) BeginPlay()

func (*World) Draw

func (w *World) Draw(screen *ebiten.Image)

func (*World) EditorBeginPlay

func (w *World) EditorBeginPlay()

func (*World) EndPlay

func (w *World) EndPlay()

func (*World) PostLoad

func (w *World) PostLoad()

func (*World) RemoveFromWorld

func (w *World) RemoveFromWorld(actor Actor)

func (*World) Update

func (w *World) Update()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL