ecs

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: CC0-1.0, MIT Imports: 5 Imported by: 40

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewQuery added in v1.2.10

func NewQuery(l LayerID, f filter.LayoutFilter) *donburi.Query

NewQuery creates a new query.

Types

type Arg added in v1.3.13

type Arg interface{}

Arg is an argument of the renderer.

type ECS

type ECS struct {
	// World is the underlying world of the ECS.
	World donburi.World
	// Time manages the time of the world.
	Time *Time
	// contains filtered or unexported fields
}

ECS represents an entity-component-system.

func NewECS

func NewECS(w donburi.World) *ECS

NewECS creates a new ECS with the specified world.

func (*ECS) AddRenderer added in v1.2.24

func (ecs *ECS) AddRenderer(l LayerID, r any) *ECS

AddRenderer adds a renderer.

func (*ECS) AddSystem

func (ecs *ECS) AddSystem(s System) *ECS

AddSystem adds a system.

func (*ECS) Create added in v1.2.10

func (ecs *ECS) Create(l LayerID, components ...donburi.IComponentType) donburi.Entity

Create creates a new entity

func (*ECS) CreateMany added in v1.2.10

func (ecs *ECS) CreateMany(l LayerID, n int, components ...donburi.IComponentType) []donburi.Entity

Create creates a new entity

func (*ECS) Draw

func (ecs *ECS) Draw(arg any)

Draw executes all draw systems.

func (*ECS) DrawLayer added in v1.2.13

func (ecs *ECS) DrawLayer(l LayerID, arg any)

DrawLayer executes all draw systems of the specified layer.

func (*ECS) IsPaused added in v1.2.11

func (ecs *ECS) IsPaused() bool

IsPaused returns a boolean value indicating whether the world is paused.

func (*ECS) Pause added in v1.2.11

func (ecs *ECS) Pause()

Pause pauses the world.

func (*ECS) Resume added in v1.2.11

func (ecs *ECS) Resume()

Resume resumes the world.

func (*ECS) Update

func (ecs *ECS) Update()

Update runs systems

type Layer added in v1.2.1

type Layer struct {
	// contains filtered or unexported fields
}

type LayerID added in v1.2.10

type LayerID int

LayerID is used to specify a layer.

const LayerDefault LayerID = 0

LayerDefault is the default layer.

type RendererWithArg added in v1.3.13

type RendererWithArg[T Arg] func(ecs *ECS, arg *T)

DrawSystem is a system that draws the world.

type System added in v1.2.1

type System func(ecs *ECS)

UpdateSystem is a system that updates the world.

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time manages the time of the world.

func NewTime

func NewTime() *Time

NewTIme creates a new Time.

func (*Time) DeltaTime

func (t *Time) DeltaTime() time.Duration

DeltaTime returns the time between the last update and the current update.

func (*Time) Pause added in v1.2.11

func (t *Time) Pause()

Pause pauses the time.

func (*Time) Resume added in v1.2.11

func (t *Time) Resume()

Resume resumes the time.

func (*Time) SetSleep added in v1.2.11

func (t *Time) SetSleep(d time.Duration)

SetSleep sets the time to sleep.

func (*Time) SetTimeScale added in v1.2.11

func (t *Time) SetTimeScale(scale float64)

SetTimeScale sets the time scale.

func (*Time) TimeScale

func (t *Time) TimeScale() float64

TimeScale returns the time scale.

func (*Time) Update

func (t *Time) Update()

Update updates the time.

Jump to

Keyboard shortcuts

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