axe

package
v0.0.0-...-20810c9 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ACTION = ecs.DefineComponent("input-action", InputActionListener{}).SetSystem(NewInputActionSystem(nil))
View Source
var AUDIO = ecs.DefineComponent("audio", AudioEmitter{})
View Source
var INPUT = ecs.DefineComponent("input", InputEvents{}).SetSystem(NewInputEventsSystem())
View Source
var LIGHT = ecs.DefineComponent("light", Light{})
View Source
var LOGIC = ecs.DefineComponent("Logic", Logic(nil)).SetSystem(NewLogicSystem())
View Source
var MESH = ecs.DefineComponent("mesh", Mesh{})
View Source
var TAG = ecs.DefineComponent("tag", Tag(""))
View Source
var TRANSFORM2 = ecs.DefineComponent("transform2", Transform3f{dirty: transformDirtyLocal}).SetSystem(NewTransformSystem3f())
View Source
var TRANSFORM3 = ecs.DefineComponent("transform3", Transform4f{dirty: transformDirtyLocal}).SetSystem(NewTransformSystem4f())

Functions

func ClampLength

func ClampLength[A Attr[A]](value A, min float32, max float32) A

Computes a value whose length is clamped between the given min and max.

func Closest

func Closest[A Attr[A]](start A, end A, point A, line bool) A

Returns the closest value to the given point on the line or segment defined by start and end.

func CubicCurve

func CubicCurve[A Attr[A]](delta float32, p0 A, p1 A, p2 A, p3 A, matrix [4][4]float32, inverse bool) A

Calculates the value on the cubic curve given a delta between 0 and 1, the 4 control points, the matrix weights, and if its an inverse.

func Delta

func Delta[A Attr[A]](start A, end A, point A) float32

A line is defined by start and end and there is a point on it that's closest to the given point. The delta value defines how close that casted point is between start and end where 0 is on start, 1 is on end, 0.5 is halfway between, and -1 is before start on the line the same distance between start and end.

func DistanceFrom

func DistanceFrom[A Attr[A]](start A, end A, point A, line bool) float32

Returns the shortest distance from the point to the line or segment defined by start and end.

func GetNormalizedDistances

func GetNormalizedDistances[T Attr[T]](points []AnimValue[T]) []float32

func GetTriangleHeight

func GetTriangleHeight(base float32, side1 float32, side2 float32) float32

Calculates the height triangle given it's base length and two sides.

func InterceptTime

func InterceptTime[A Attr[A]](interceptor A, interceptorSpeed float32, targetPosition A, targetVelocity A) float32

Calculates the time an interceptor could intercept a target given the interceptors position and possible speed and the targets current position and velocity. If no intercept exists based on the parameters then -1 is returned. Otherwise a value is returned that can be used to calculate the interception point (targetPosition+(targetVelocity*time)).

func IsCircleInView

func IsCircleInView[A Attr[A]](viewOrigin A, viewDirection A, fovTan float32, fovCos float32, circle A, circleRadius float32, entirely bool) bool

Returns true if the circle is fully or partially in the defined conical view.

func IsCircleInViewType

func IsCircleInViewType[A Attr[A]](viewOrigin A, viewDirection A, fovTan float32, fovCos float32, circle A, circleRadius float32, fovType FieldOfView) bool

Returns true if the circle is in the defined view based on FOV option.

func IsNormal

func IsNormal[A Attr[A]](value A) bool

Returns if the given value is normalized (has a length of 1).

func IsPointInView

func IsPointInView[A Attr[A]](viewOrigin A, viewDirection A, fovCos float32, point A) bool

Returns true if the point is in the defined conical view.

func Lengthen

func Lengthen[A Attr[A]](value A, length float32) A

Computes a value with the given length.

func NewBehaviorSystem

func NewBehaviorSystem[B any]() ecs.DataSystem[B]

func NewInputActionSystem

func NewInputActionSystem(unhandled input.ActionHandler) ecs.DataSystem[InputActionListener]

func NewInputEventsSystem

func NewInputEventsSystem() ecs.DataSystem[InputEvents]

func NewLogicSystem

func NewLogicSystem() ecs.DataSystem[Logic]

func NewTransformSystem

func NewTransformSystem[A Attr[A]]() ecs.DataSystem[Transform[A]]

func NewTransformSystem3f

func NewTransformSystem3f() ecs.DataSystem[Transform3f]

func NewTransformSystem4f

func NewTransformSystem4f() ecs.DataSystem[Transform4f]

func NewUserInterfaceSystem

func NewUserInterfaceSystem() ecs.DataSystem[UserInterface]

func Normalize

func Normalize[A Attr[A]](value A, normal *A) float32

Sets normal to the given value but with a length of 1 or 0.

func ParametricCubicCurve

func ParametricCubicCurve[A Attr[A]](delta float32, points []A, matrix [4][4]float32, weight float32, inverse bool, loop bool) A

Calculates a parametric cubic curve given a delta between 0 and 1, the points of the curve, the weights, if its inversed, and if the curve loops.

func Reflect

func Reflect[A Attr[A]](dir A, normal A) A

Reflects the direction across a given normal. Imagine the normal is on a plane pointing away from it and a reflection is a ball with the given direction bouncing off of it.

func Refract

func Refract[A Attr[A]](dir A, normal A) A

Refracts the direction across the given normal. Like reflect except through the plane defined by the normal.

func Resolve

func Resolve[T any](value any) T

func Slerp

func Slerp[A Attr[A]](start A, end A, t float32) A

Performs a slerp between two values. Imagine the two values define a curve that lies on an ellipse where the zero value is the center. The returned value will exist on that curve where 0 is at start and 1 is at end and 0.5 is halfway between.

func SlerpAngle

func SlerpAngle[A Attr[A]](start A, end A, angle float32, t float32) A

Performs a slerp between the start and end value given the curves "angle" between the two values and a t value. When t is 0 the returned value will equal start and when 1 will match end. Angle is in radians.

func SlerpNormal

func SlerpNormal[A Attr[A]](start A, end A, t float32) A

Performs a slerp between two normals given a t. The returned value will exist on the shortest curve from the end of start and end and t between those two values (t is 0 to 1).

Types

type AnimConstant

type AnimConstant[T any] struct {
	Value T
}

func (AnimConstant[T]) Get

func (con AnimConstant[T]) Get() T

type AnimValue

type AnimValue[T any] interface {
	Get() T
}

type AssetSystem

type AssetSystem struct {
	asset.Assets
}

func NewAssetSystem

func NewAssetSystem() AssetSystem

func (*AssetSystem) Init

func (assets *AssetSystem) Init(game *Game) error

func (*AssetSystem) Update

func (assets *AssetSystem) Update(game *Game)

type Attr

type Attr[V any] interface {
	// distance between this and value
	Distance(value V) float32
	// squared distance between this and value
	DistanceSq(value V) float32
	// distance between this and zero
	Length() float32
	// squared distance between this and zero
	LengthSq() float32
	// dot product between this and value
	Dot(value V) float32
	// the number of float components that make up this attribute
	Components() int
	// gets the float component at the given index
	GetComponent(index int) float32
	// out[index] = value
	SetComponent(index int, value float32, out *V)
	// out[all] = value
	SetComponents(value float32, out *V)
	// out = this
	Set(out *V)
	// out = this + value
	Add(addend V, out *V)
	// out = this + value * scale
	AddScaled(value V, scale float32, out *V)
	// out = this - value
	Sub(subtrahend V, out *V)
	// out = this * value
	Mul(factor V, out *V)
	// out = this / value
	Div(factor V, out *V)
	// out = this * scale
	Scale(scale float32, out *V)
	// out = (end - start) * delta + start
	Lerp(end V, delta float32, out *V)
}

An attribute in the game that has basic math operations.

type AudioAmbience

type AudioAmbience struct {
	PlayChance           int
	Options              []AudioAmbienceOption
	Volume               float32
	MaxPlaysBeforeRepeat int
	TransitionTime       NumericRange[float32]
}

type AudioAmbienceOption

type AudioAmbienceOption struct {
	Data       *AudioData
	Chance     int
	PlayVolume NumericRange[float32]
	PlayLength NumericRange[float32]
}

type AudioAttenuation

type AudioAttenuation func(distance float32, volume float32) float32

type AudioData

type AudioData struct {
	Length    int
	Streaming bool
	BitRate   int
	Reader    io.ReadSeekCloser
}

type AudioEmitter

type AudioEmitter struct {
	Source   AudioSource
	Pending  []AudioRequest
	Ambience *AudioAmbience
}

func (*AudioEmitter) Play

func (audio *AudioEmitter) Play(req AudioRequest)

type AudioInstance

type AudioInstance struct {
	Name           string
	Flags          uint
	Data           *AudioData
	Position       SpaceCoord // optional for spatial sounds
	Direction      SpaceCoord // optional for directional sounds
	PositionVolume float32    // volume at position
	Speed          float32    // playback rate modifier
	StartTime      time.Time
	PauseTime      time.Time
	Settings       *AudioInstanceSettings // custom or shared
	// relative to current listener
	Distance       float32
	ListenerVolume float32
	LeftVolume     float32
	RightVolume    float32
}

type AudioInstanceSettings

type AudioInstanceSettings struct {
	DirectionSpread     float32 // optional for direction sounds, how big the noise cone is
	StartOnRequest      bool    // if we set the start time when sound playing is requested, or when it actually starts. this plays into if we seek to the position the audio should've been playing by the time it was ready
	Times               int     // -1=Infinite loop
	Attenuate           AudioAttenuation
	IsVirtual           bool
	OnVirtual           AudioVirtualOp
	VirtualOutroTime    time.Duration // how long we fade out when going virtual
	VirtualMinRemaining time.Duration // if we are going virtual and not stopping but have <= this left then we just stop
	Importance          float32       // scales the listener volume by this amount to calculate a priority
}

type AudioListener

type AudioListener struct {
	Name          string
	Flags         uint
	Position      SpaceCoord
	Direction     SpaceCoord
	Ears          SpaceCoord // Camera position?
	EarsDirection SpaceCoord
	VolumeScale   float32
}

type AudioRequest

type AudioRequest struct {
	MaxWaitTime time.Duration
	Instance    AudioInstance
}

type AudioSettings

type AudioSettings struct {
	AudioUnloadTime   time.Duration // how long to wait before we unload unused audio
	MaxAudioInstances int           // user specified, otherwise determined by available APIs or trial & error
}

type AudioSource

type AudioSource struct {
	Name                string
	Flags               uint
	Position            SpaceCoord
	Direction           SpaceCoord
	DirectionInner      float32
	DirectionOuter      float32
	DirectionOuterScale float32
	Instances           []AudioInstance
}

this component can emit audio, and the audio is tied to it. if the component is destroyed the audio is as well.

type AudioSystem

type AudioSystem interface {
	GameSystem

	Listeners() []AudioListener
	Instances() []AudioInstance
	Settings() map[string]AudioSettings
	Sources() []AudioSource
	EntitySystem() ecs.DataSystem[AudioEmitter]
}

type AudioVirtualOp

type AudioVirtualOp string
const (
	AudioVirtualOpStop    AudioVirtualOp = "stop"    // when going virtual, stop and ignore the audio
	AudioVirtualOpRestart AudioVirtualOp = "restart" // when coming back from virtual, restart from start
	AudioVirtualOpPause   AudioVirtualOp = "pause"   // when going virtual remember place in audio, and when coming back from virtual start at that place
	AudioVirtualOpPlay    AudioVirtualOp = "play"    // when going virtual remember place in audio and when it comes out of virtual play as if we could hear it the whole time
)

type BehaviorOnLive

type BehaviorOnLive interface {
	OnLive(e *ecs.Entity, ctx ecs.Context)
}

type BehaviorOnRemove

type BehaviorOnRemove interface {
	OnRemove(e *ecs.Entity, ctx ecs.Context)
}

type BehaviorOnStage

type BehaviorOnStage interface {
	OnStage(e *ecs.Entity, ctx ecs.Context)
}

type BehaviorOnUpdate

type BehaviorOnUpdate interface {
	Update(e *ecs.Entity, ctx ecs.Context)
}

type BehaviorSystem

type BehaviorSystem[B any] struct{}

func (BehaviorSystem[B]) Destroy

func (sys BehaviorSystem[B]) Destroy(ctx ecs.Context)

func (BehaviorSystem[B]) Init

func (sys BehaviorSystem[B]) Init(ctx ecs.Context) error

func (BehaviorSystem[B]) OnLive

func (sys BehaviorSystem[B]) OnLive(data *B, e *ecs.Entity, ctx ecs.Context)

func (BehaviorSystem[B]) OnRemove

func (sys BehaviorSystem[B]) OnRemove(data *B, e *ecs.Entity, ctx ecs.Context)

func (BehaviorSystem[B]) OnStage

func (sys BehaviorSystem[B]) OnStage(data *B, e *ecs.Entity, ctx ecs.Context)

func (BehaviorSystem[B]) Update

func (sys BehaviorSystem[B]) Update(iter ds.Iterable[ecs.Value[*B]], ctx ecs.Context)

type Bounds

type Bounds[A Attr[A]] struct {
	Min       A
	Max       A
	Thickness float32
}

func (Bounds[A]) Bounds

func (b Bounds[A]) Bounds(bounds *Bounds[A]) bool

func (Bounds[A]) Corner

func (b Bounds[A]) Corner(cornerIndex int) A

func (Bounds[A]) CornerCount

func (b Bounds[A]) CornerCount() int

func (Bounds[A]) Corners

func (b Bounds[A]) Corners() []A

func (Bounds[A]) Distance

func (b Bounds[A]) Distance(point A) float32

func (Bounds[A]) DistanceSq

func (b Bounds[A]) DistanceSq(point A) float32

func (Bounds[A]) Finite

func (b Bounds[A]) Finite() bool

func (Bounds[A]) Normal

func (b Bounds[A]) Normal(point A, out *A) bool

func (Bounds[A]) PlaneSign

func (b Bounds[A]) PlaneSign(plane Plane[A]) PlaneSign

func (Bounds[A]) Raytrace

func (b Bounds[A]) Raytrace(point A, direction A) bool

func (Bounds[A]) Round

func (b Bounds[A]) Round(round *Round[A]) bool

func (Bounds[A]) Transform

func (b Bounds[A]) Transform(shapeTransform Trans[A]) Shape[A]

type Bounds2f

type Bounds2f = Bounds[Vec2f]

type Camera

type Camera[A Attr[A]] interface {
	GameSystem

	GetTransform() Trans[A]
	GetPlanes() []Plane[A]
	GetMatrix() Mat[A]
}

type Camera2d

type Camera2d struct {
	Transform Trans2d
	Size      Vec2d
	Near      Scalarf
	Far       Scalarf

	Up     Vec2d
	Right  Vec2d
	Left   Vec2d
	Down   Vec2d
	Min    Vec2d
	Max    Vec2d
	Aspect Scalarf
	Planes [4]Plane2d
	Matrix Mat2d
}

func NewCamera2d

func NewCamera2d() Camera2d

func (*Camera2d) Destroy

func (c *Camera2d) Destroy()

func (*Camera2d) GetMatrix

func (c *Camera2d) GetMatrix() Mat[Vec2d]

func (*Camera2d) GetPlanes

func (c *Camera2d) GetPlanes() []Plane[Vec2d]

func (*Camera2d) GetTransform

func (c *Camera2d) GetTransform() Trans[Vec2d]

func (*Camera2d) Init

func (c *Camera2d) Init(game *Game) error

func (*Camera2d) Update

func (c *Camera2d) Update(game *Game)

type Camera3d

type Camera3d struct {
	Transform Trans3d
	Size      Vec2d
	Near      Scalarf
	Far       Scalarf
	Fov       Scalarf

	Up       Vec3d
	Right    Vec3d
	Left     Vec3d
	Down     Vec3d
	Forward  Vec3d
	Backward Vec3d
	Min      Vec3d
	Max      Vec3d
	Aspect   Scalarf
	Planes   [6]Plane3d
	Matrix   Mat3d
}

func NewCamera3d

func NewCamera3d() Camera3d

func (*Camera3d) Destroy

func (c *Camera3d) Destroy()

func (*Camera3d) GetMatrix

func (c *Camera3d) GetMatrix() Mat[Vec3d]

func (Camera3d) GetPlanes

func (c Camera3d) GetPlanes() []Plane[Vec3d]

func (Camera3d) GetTransform

func (c Camera3d) GetTransform() Trans[Vec3d]

func (*Camera3d) Init

func (c *Camera3d) Init(game *Game) error

func (*Camera3d) Update

func (c *Camera3d) Update(game *Game)

type Circle

type Circle = Round[Vec2f]

type Computed

type Computed[T any] interface {
	Compute(current *T)
}

type DebugEvent

type DebugEvent struct {
	Id       int
	Name     string
	Parent   *DebugEvent
	Depth    int
	Children []*DebugEvent
	Sibling  *DebugEvent
}

type DebugGraph

type DebugGraph struct {
	Placement ui.Placement
	Database  *StatDatabase
	Set       *StatSet
}

type DebugLog

type DebugLog struct {
	Severity int
	Message  string
	Data     any
}

type DebugProfiler

type DebugProfiler struct{}

func (*DebugProfiler) Begin

func (prof *DebugProfiler) Begin(ev string)

func (*DebugProfiler) End

func (prof *DebugProfiler) End()

type DebugSnapshot

type DebugSnapshot struct {
	At      time.Time
	Elapsed time.Duration
}

type DebugSystem

type DebugSystem struct {
	Logs      []DebugLog
	Snapshots []DebugSnapshot
	Graphs    []DebugGraph
	Events    []DebugEvent
	Enabled   bool
}

func (*DebugSystem) Destroy

func (ds *DebugSystem) Destroy()

func (*DebugSystem) Init

func (ds *DebugSystem) Init(game *Game) error

func (*DebugSystem) LogDebug

func (ds *DebugSystem) LogDebug(format string, values ...any)

func (*DebugSystem) LogError

func (ds *DebugSystem) LogError(err error)

func (*DebugSystem) Trigger

func (ds *DebugSystem) Trigger(ev DebugEvent)

func (*DebugSystem) Update

func (ds *DebugSystem) Update(game *Game)

type Dynamic

type Dynamic[T any] interface {
	Get() T
}

type EventSystem

type EventSystem struct {
}

func (*EventSystem) Destroy

func (events *EventSystem) Destroy()

func (*EventSystem) Init

func (events *EventSystem) Init(game *Game) error

func (*EventSystem) Update

func (events *EventSystem) Update(game *Game)

type Face

type Face struct {
	Vertices []int
	Uvs      []int
	Normals  []int
}

type FieldOfView

type FieldOfView string
const (
	FieldOfViewIgnore FieldOfView = "ignore"
	FieldOfViewHalf   FieldOfView = "half"
	FieldOfViewFull   FieldOfView = "full"
)

type FontBitmapFormat

type FontBitmapFormat struct{}

func (*FontBitmapFormat) Activate

func (loader *FontBitmapFormat) Activate(a *asset.Asset) error

func (*FontBitmapFormat) Deactivate

func (loader *FontBitmapFormat) Deactivate(a *asset.Asset) error

func (*FontBitmapFormat) Handles

func (loader *FontBitmapFormat) Handles(ref asset.Ref) bool

func (*FontBitmapFormat) Load

func (loader *FontBitmapFormat) Load(a *asset.Asset) error

func (*FontBitmapFormat) Types

func (loader *FontBitmapFormat) Types() []asset.Type

func (*FontBitmapFormat) Unload

func (loader *FontBitmapFormat) Unload(a *asset.Asset) error

type Game

type Game struct {
	Debug    DebugSystem
	Assets   AssetSystem
	Windows  WindowSystem
	Graphics GraphicsSystem
	Input    InputSystem
	Actions  input.ActionSets
	Audio    AudioSystem
	Events   EventSystem
	Stages   StageManager
	State    GameState
	Settings GameSettings
	Running  bool
}

func ActiveGame

func ActiveGame() *Game

func NewGame

func NewGame(settings GameSettings) *Game

func (*Game) Activate

func (game *Game) Activate()

func (*Game) Destroy

func (game *Game) Destroy()

func (*Game) Init

func (game *Game) Init() error

func (*Game) IsActive

func (game *Game) IsActive() bool

func (*Game) Run

func (game *Game) Run() error

func (*Game) Tick

func (game *Game) Tick() error

type GameSettings

type GameSettings struct {
	Name                 string
	EnableDebug          bool
	FixedUpdateFrequency time.Duration
	FixedDrawFrequency   time.Duration
	FirstStage           string
	JobGroups            int
	JobBudget            int
	Stages               []Stage
	Assets               []asset.Ref
	Windows              []StageWindow
	WorldName            string
	WorldSettings        ecs.WorldSettings
}

type GameState

type GameState struct {
	StartTime   time.Time
	UpdateTimer Timer
	DrawTimer   Timer
}

func (*GameState) FromSettings

func (state *GameState) FromSettings(settings GameSettings)

type GameSystem

type GameSystem interface {
	Init(game *Game) error
	Update(game *Game)
	Destroy()
}

type GraphicsSystem

type GraphicsSystem interface {
	GameSystem
}

type InputActionListener

type InputActionListener struct {
	Handler func(action *input.Action) bool
}

type InputActionSystem

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

func (*InputActionSystem) Destroy

func (sys *InputActionSystem) Destroy(ctx ecs.Context)

func (*InputActionSystem) Init

func (sys *InputActionSystem) Init(ctx ecs.Context) error

func (InputActionSystem) OnLive

func (sys InputActionSystem) OnLive(data *InputActionListener, e *ecs.Entity, ctx ecs.Context)

func (InputActionSystem) OnRemove

func (sys InputActionSystem) OnRemove(data *InputActionListener, e *ecs.Entity, ctx ecs.Context)

func (InputActionSystem) OnStage

func (sys InputActionSystem) OnStage(data *InputActionListener, e *ecs.Entity, ctx ecs.Context)

func (*InputActionSystem) Update

type InputEvents

type InputEvents = input.SystemEvents

func UserInterfaceInputEventsFor

func UserInterfaceInputEventsFor(e *ecs.Entity) InputEvents

type InputEventsSystem

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

func (*InputEventsSystem) Destroy

func (sys *InputEventsSystem) Destroy(ctx ecs.Context)

func (*InputEventsSystem) Init

func (sys *InputEventsSystem) Init(ctx ecs.Context) error

func (InputEventsSystem) OnLive

func (sys InputEventsSystem) OnLive(data *InputEvents, e *ecs.Entity, ctx ecs.Context)

func (InputEventsSystem) OnRemove

func (sys InputEventsSystem) OnRemove(data *InputEvents, e *ecs.Entity, ctx ecs.Context)

func (InputEventsSystem) OnStage

func (sys InputEventsSystem) OnStage(data *InputEvents, e *ecs.Entity, ctx ecs.Context)

func (*InputEventsSystem) Update

func (sys *InputEventsSystem) Update(iter ds.Iterable[ecs.Value[*InputEvents]], ctx ecs.Context)

type InputSystem

type InputSystem interface {
	GameSystem
	input.InputSystem
}

type Integer

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Light

type Light struct {
	Ambient       color.Color
	Diffuse       color.Color
	Specular      color.Color
	Position      Vec4f
	SpotDirection Vec4f
	SpotExponent  uint8
	SpotCutOff    uint8
	Attenuate     LightAttenuate
}

type LightAttenuate

type LightAttenuate int
const (
	LightAttenuateNone LightAttenuate = iota
	LightAttenuateConstant
	LightAttenuateLinear
	LightAttenuateQuadratic
)

type Line

type Line[A Attr[A]] struct {
	Start A
	End   A
}

func (Line[A]) Diff

func (l Line[A]) Diff() A

func (Line[A]) PlaneSign

func (l Line[A]) PlaneSign(plane Plane[A]) PlaneSign

type Logic

type Logic func(e *ecs.Entity, ctx ecs.Context)

type LogicSystem

type LogicSystem struct{}

func (LogicSystem) Destroy

func (sys LogicSystem) Destroy(ctx ecs.Context)

func (LogicSystem) Init

func (sys LogicSystem) Init(ctx ecs.Context) error

func (LogicSystem) OnLive

func (sys LogicSystem) OnLive(data *Logic, e *ecs.Entity, ctx ecs.Context)

func (LogicSystem) OnRemove

func (sys LogicSystem) OnRemove(data *Logic, e *ecs.Entity, ctx ecs.Context)

func (LogicSystem) OnStage

func (sys LogicSystem) OnStage(data *Logic, e *ecs.Entity, ctx ecs.Context)

func (LogicSystem) Update

func (sys LogicSystem) Update(iter ds.Iterable[ecs.Value[*Logic]], ctx ecs.Context)

type Mat

type Mat[A Attr[A]] interface {
	Get() []float32
	Set(values []float32)
	Identity()
	Transform(v A) A
	Multiply(other Mat[A])
	Invert()
}

type Mat2d

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

func (*Mat2d) Determinant

func (m *Mat2d) Determinant() float32

func (*Mat2d) Get

func (m *Mat2d) Get() []float32

func (*Mat2d) Identity

func (m *Mat2d) Identity()

func (*Mat2d) Invert

func (m *Mat2d) Invert()

func (*Mat2d) Multiply

func (m *Mat2d) Multiply(other Mat[Vec2d])

func (*Mat2d) Ortho

func (m *Mat2d) Ortho(left, top, right, bottom float32)

func (*Mat2d) Set

func (m *Mat2d) Set(values []float32)

func (*Mat2d) Transform

func (m *Mat2d) Transform(v Vec2d) Vec2d

type Mat3d

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

func (*Mat3d) Determinant

func (m *Mat3d) Determinant() float32

func (*Mat3d) Get

func (m *Mat3d) Get() []float32

func (*Mat3d) Identity

func (m *Mat3d) Identity()

func (*Mat3d) Invert

func (m *Mat3d) Invert()

func (*Mat3d) Multiply

func (m *Mat3d) Multiply(other Mat[Vec3d])

func (*Mat3d) Ortho

func (m *Mat3d) Ortho(left, right, bottom, top float32)

func (*Mat3d) Perpsective

func (m *Mat3d) Perpsective(fov, aspectRatio, near, far float32)

func (*Mat3d) Set

func (m *Mat3d) Set(values []float32)

func (*Mat3d) Transform

func (m *Mat3d) Transform(v Vec3d) Vec3d

func (*Mat3d) TransformVector

func (m *Mat3d) TransformVector(v Vec3d) Vec3d

type Material

type Material struct {
	Name        string       // Material name
	Illum       int          // Illumination model
	Opacity     float32      // Opacity factor
	Refraction  float32      // Refraction factor
	Shininess   float32      // Shininess (specular exponent)
	Ambient     TextureColor // Ambient color reflectivity
	Diffuse     TextureColor // Diffuse color reflectivity
	Specular    TextureColor // Specular color reflectivity
	Emissive    TextureColor // Emissive color
	TextureBump string
}

type Materials

type Materials map[string]Material

type Matrix

type Matrix[A Attr[A]] struct {
	// contains filtered or unexported fields
}

func InitMatrix

func InitMatrix[A Attr[A]](m Matrix[A]) Matrix[A]

func NewMatrix

func NewMatrix[A Attr[A]]() Matrix[A]

func (*Matrix[A]) Adjoint

func (m *Matrix[A]) Adjoint(other Matrix[A])

func (*Matrix[A]) Cofactor

func (m *Matrix[A]) Cofactor(other Matrix[A])

func (*Matrix[A]) Col

func (m *Matrix[A]) Col(index int) A

func (*Matrix[A]) Determinant

func (m *Matrix[A]) Determinant() float32

func (Matrix[A]) GetValues

func (m Matrix[A]) GetValues() [][]float32

func (*Matrix[A]) Identity

func (m *Matrix[A]) Identity()

func (*Matrix[A]) Invert

func (m *Matrix[A]) Invert(other Matrix[A])

func (*Matrix[A]) Minor

func (m *Matrix[A]) Minor(other Matrix[A])

func (*Matrix[A]) Mul

func (m *Matrix[A]) Mul(base Matrix[A], other Matrix[A])

func (*Matrix[A]) PostTranslate

func (m *Matrix[A]) PostTranslate(translation A)

func (*Matrix[A]) Rotate

func (m *Matrix[A]) Rotate(radians A, hasTranslation bool)

func (*Matrix[A]) Row

func (m *Matrix[A]) Row(index int) A

func (*Matrix[A]) Scale

func (m *Matrix[A]) Scale(scale A)

func (*Matrix[A]) Set

func (m *Matrix[A]) Set(other Matrix[A])

func (*Matrix[A]) SetAxisRotaton

func (m *Matrix[A]) SetAxisRotaton(radians float32, axis int, hasTranslation bool)

func (*Matrix[A]) SetCol

func (m *Matrix[A]) SetCol(index int, col A)

func (*Matrix[A]) SetRotaton

func (m *Matrix[A]) SetRotaton(radians A, hasTranslation bool)

func (*Matrix[A]) SetRow

func (m *Matrix[A]) SetRow(index int, row A)

func (*Matrix[A]) SetScale

func (m *Matrix[A]) SetScale(scale A)

func (*Matrix[A]) SetTranslation

func (m *Matrix[A]) SetTranslation(translation A)

func (*Matrix[A]) SetValues

func (m *Matrix[A]) SetValues(values [][]float32)

func (Matrix[A]) Size

func (m Matrix[A]) Size() int

func (Matrix[A]) Transform

func (m Matrix[A]) Transform(point A) A

func (Matrix[A]) TransformVector

func (m Matrix[A]) TransformVector(point A) A

func (*Matrix[A]) Translate

func (m *Matrix[A]) Translate(translation A)

func (*Matrix[A]) Transpose

func (m *Matrix[A]) Transpose(other Matrix[A])

func (*Matrix[A]) Zero

func (m *Matrix[A]) Zero()

type Matrix2f

type Matrix2f = Matrix[Vec2f]

type Matrix3f

type Matrix3f = Matrix[Vec3f]

type Matrix4f

type Matrix4f = Matrix[Vec4f]

type Mesh

type Mesh struct {
	Ref asset.Ref
	// contains filtered or unexported fields
}

type MeshData

type MeshData struct {
	Name      string
	Vertices  [][3]float32
	Normals   [][3]float32
	Uvs       [][2]float32
	Groups    []MeshFaceGroup
	Materials string
}

type MeshFaceGroup

type MeshFaceGroup struct {
	Material string
	Faces    []Face
}

type MtlFormat

type MtlFormat struct {
}

func (*MtlFormat) Activate

func (format *MtlFormat) Activate(asset *asset.Asset) error

func (*MtlFormat) Deactivate

func (format *MtlFormat) Deactivate(asset *asset.Asset) error

func (*MtlFormat) Handles

func (format *MtlFormat) Handles(ref asset.Ref) bool

func (*MtlFormat) Load

func (format *MtlFormat) Load(a *asset.Asset) error

func (*MtlFormat) Types

func (format *MtlFormat) Types() []asset.Type

func (*MtlFormat) Unload

func (format *MtlFormat) Unload(asset *asset.Asset) error

type NoAudioSystem

type NoAudioSystem struct{}

func (*NoAudioSystem) Destroy

func (audio *NoAudioSystem) Destroy()

func (*NoAudioSystem) EntitySystem

func (audio *NoAudioSystem) EntitySystem() ecs.DataSystem[AudioEmitter]

func (*NoAudioSystem) Init

func (audio *NoAudioSystem) Init(game *Game) error

func (*NoAudioSystem) Instances

func (audio *NoAudioSystem) Instances() []AudioInstance

func (*NoAudioSystem) Listeners

func (audio *NoAudioSystem) Listeners() []AudioListener

func (*NoAudioSystem) Settings

func (audio *NoAudioSystem) Settings() map[string]AudioSettings

func (*NoAudioSystem) Sources

func (audio *NoAudioSystem) Sources() []AudioSource

func (*NoAudioSystem) Update

func (audio *NoAudioSystem) Update(game *Game)

type NoGraphicsSystem

type NoGraphicsSystem struct{}

func (*NoGraphicsSystem) Destroy

func (gr *NoGraphicsSystem) Destroy()

func (*NoGraphicsSystem) Init

func (gr *NoGraphicsSystem) Init(game *Game) error

func (*NoGraphicsSystem) Update

func (gr *NoGraphicsSystem) Update(game *Game)

type NoInputSystem

type NoInputSystem struct {
	input.EmptySystem
}

func (*NoInputSystem) Destroy

func (in *NoInputSystem) Destroy()

func (*NoInputSystem) Init

func (in *NoInputSystem) Init(game *Game) error

func (*NoInputSystem) Update

func (in *NoInputSystem) Update(game *Game)

type NoWindowSystem

type NoWindowSystem struct{}

func (*NoWindowSystem) Destroy

func (windows *NoWindowSystem) Destroy()

func (*NoWindowSystem) Events

func (windows *NoWindowSystem) Events() *core.Listeners[WindowSystemEvents]

func (*NoWindowSystem) Init

func (windows *NoWindowSystem) Init(game *Game) error

func (*NoWindowSystem) MainWindow

func (windows *NoWindowSystem) MainWindow() Window

func (*NoWindowSystem) Screens

func (windows *NoWindowSystem) Screens() []Screen

func (*NoWindowSystem) Update

func (windows *NoWindowSystem) Update(game *Game)

func (*NoWindowSystem) Windows

func (windows *NoWindowSystem) Windows() []Window

type Numeric

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64
}

type NumericRange

type NumericRange[D Numeric] struct {
	Min D
	Max D
}

func (NumericRange[D]) At

func (r NumericRange[D]) At(delta float32) D

func (NumericRange[D]) Random

func (r NumericRange[D]) Random(rnd rand.Rand) D

type ObjFormat

type ObjFormat struct {
}

func (*ObjFormat) Activate

func (format *ObjFormat) Activate(asset *asset.Asset) error

func (*ObjFormat) Deactivate

func (format *ObjFormat) Deactivate(asset *asset.Asset) error

func (*ObjFormat) Handles

func (format *ObjFormat) Handles(ref asset.Ref) bool

func (*ObjFormat) Load

func (format *ObjFormat) Load(asset *asset.Asset) error

func (*ObjFormat) Types

func (format *ObjFormat) Types() []asset.Type

func (*ObjFormat) Unload

func (format *ObjFormat) Unload(asset *asset.Asset) error

type Path

type Path[T Attr[T]] interface {
	Set(out *T, delta float32)
	PointCount() int
	Point(index int) AnimValue[T]
	Flags() PathFlag
}

type PathDelta

type PathDelta[T Attr[T]] struct {
	Deltas []float32
	Points []AnimValue[T]
}

func (PathDelta[T]) Flags

func (path PathDelta[T]) Flags() PathFlag

func (PathDelta[T]) Point

func (path PathDelta[T]) Point(index int) AnimValue[T]

func (PathDelta[T]) PointCount

func (path PathDelta[T]) PointCount() int

func (PathDelta[T]) Set

func (path PathDelta[T]) Set(out *T, delta float32)

type PathFlag

type PathFlag int
const (
	PathFlagCyclic PathFlag = 1 << iota
	PathFlagCurved
	PathFlagContinuous
)

func (PathFlag) Has

func (flag PathFlag) Has(flags PathFlag) bool

type PathLinear

type PathLinear[T Attr[T]] struct {
	Inner PathDelta[T]
}

func NewPathLinear

func NewPathLinear[T Attr[T]](points []AnimValue[T]) PathLinear[T]

func (PathLinear[T]) Flags

func (path PathLinear[T]) Flags() PathFlag

func (PathLinear[T]) Point

func (path PathLinear[T]) Point(index int) AnimValue[T]

func (PathLinear[T]) PointCount

func (path PathLinear[T]) PointCount() int

func (PathLinear[T]) Set

func (path PathLinear[T]) Set(out *T, delta float32)

type PathPoint

type PathPoint[T Attr[T]] struct {
	Value AnimValue[T]
}

func (PathPoint[T]) Flags

func (path PathPoint[T]) Flags() PathFlag

func (PathPoint[T]) Point

func (path PathPoint[T]) Point(index int) AnimValue[T]

func (PathPoint[T]) PointCount

func (path PathPoint[T]) PointCount() int

func (PathPoint[T]) Set

func (path PathPoint[T]) Set(out *T, delta float32)

type Plane

type Plane[A Attr[A]] interface {
	SetPointNormal(point A, normal A)
	SetPoints(points []A)
	Distance(point A) float32
	GetPoint() A
	GetNormal() A
	Sign(point A) PlaneSign
}

type Plane2d

type Plane2d struct {
	A, B, C float32
}

func (*Plane2d) Distance

func (p *Plane2d) Distance(point Vec2d) float32

func (*Plane2d) GetNormal

func (p *Plane2d) GetNormal() Vec2d

func (*Plane2d) GetPoint

func (p *Plane2d) GetPoint() Vec2d

func (*Plane2d) Intersection

func (p *Plane2d) Intersection(plane Plane[Vec2d], out *Vec2d) bool

func (*Plane2d) SetPointNormal

func (p *Plane2d) SetPointNormal(point Vec2d, normal Vec2d)

func (*Plane2d) SetPoints

func (p *Plane2d) SetPoints(points []Vec2d)

func (*Plane2d) Sign

func (p *Plane2d) Sign(point Vec2d) PlaneSign

type Plane3d

type Plane3d struct {
	A, B, C, D float32
}

func (*Plane3d) Clip

func (p *Plane3d) Clip(line Line[Vec3d], side PlaneSign) *Line[Vec3d]

func (*Plane3d) Distance

func (p *Plane3d) Distance(point Vec3d) float32

func (*Plane3d) DistanceLine

func (p *Plane3d) DistanceLine(line Line[Vec3d]) float32

func (*Plane3d) DistanceRound

func (p *Plane3d) DistanceRound(round Round[Vec3d]) float32

func (*Plane3d) GetNormal

func (p *Plane3d) GetNormal() Vec3d

func (*Plane3d) GetPoint

func (p *Plane3d) GetPoint() Vec3d

func (*Plane3d) Intersection

func (p *Plane3d) Intersection(plane Plane[Vec3d], out *Line[Vec3d]) bool

func (*Plane3d) SetPointNormal

func (p *Plane3d) SetPointNormal(point Vec3d, normal Vec3d)

func (*Plane3d) SetPoints

func (p *Plane3d) SetPoints(points []Vec3d)

func (*Plane3d) Sign

func (p *Plane3d) Sign(point Vec3d) PlaneSign

func (*Plane3d) SignPoints

func (p *Plane3d) SignPoints(points []Vec3d) PlaneSign

type PlaneSign

type PlaneSign int
const (
	PlaneSignBack PlaneSign = iota - 1
	PlaneSignOn
	PlaneSignFront
	PlaneSignIntersects
)

type ProjectionOutside

type ProjectionOutside int
const (
	ProjectionOutsideIgnore ProjectionOutside = iota
	ProjectionOutsideClamp
	ProjectionOutsideRelative
)

type Quat

type Quat struct {
	X, Y, Z, W float32
}

func (Quat) Add

func (q Quat) Add(value Quat, out *Quat)

func (Quat) AddScaled

func (q Quat) AddScaled(value Quat, amount float32, out *Quat)

func (Quat) AngleBetween

func (q1 Quat) AngleBetween(q2 Quat) float32

func (Quat) Components

func (q Quat) Components() int

func (*Quat) Conjugate

func (q *Quat) Conjugate()

func (Quat) Distance

func (q Quat) Distance(other Quat) float32

func (Quat) DistanceSq

func (q Quat) DistanceSq(other Quat) float32

func (Quat) Div

func (a Quat) Div(b Quat, out *Quat)

func (Quat) Dot

func (q1 Quat) Dot(q2 Quat) float32

func (Quat) GetAngle

func (q Quat) GetAngle() (dir Vec3f, angle float32)

func (Quat) GetComponent

func (q Quat) GetComponent(index int) float32

func (Quat) GetEuler

func (q Quat) GetEuler() Vec3f

func (*Quat) Invert

func (q *Quat) Invert()

func (Quat) Length

func (q Quat) Length() float32

func (Quat) LengthSq

func (q Quat) LengthSq() float32

func (Quat) Lerp

func (start Quat) Lerp(end Quat, delta float32, out *Quat)

func (Quat) Mul

func (a Quat) Mul(b Quat, out *Quat)

func (*Quat) Multiply

func (q *Quat) Multiply(a Quat, b Quat)

func (*Quat) MultiplyValues

func (q *Quat) MultiplyValues(aX, aY, aZ, aW, bX, bY, bZ, bW float32)

func (*Quat) Normal

func (q *Quat) Normal() float32

func (Quat) Rotate

func (q Quat) Rotate(v Vec3f, out *Vec3f)

func (*Quat) RotateAround

func (q *Quat) RotateAround(point Vec3f, angle float32, axis Vec3f)

func (Quat) Scale

func (q Quat) Scale(amount float32, out *Quat)

func (Quat) Set

func (q Quat) Set(out *Quat)

func (*Quat) SetAngle

func (q *Quat) SetAngle(dir Vec3f, angle float32)

func (Quat) SetComponent

func (q Quat) SetComponent(index int, value float32, out *Quat)

func (Quat) SetComponents

func (q Quat) SetComponents(value float32, out *Quat)

func (*Quat) SetEuler

func (q *Quat) SetEuler(yaw float32, pitch float32, roll float32)

func (*Quat) Sets

func (q *Quat) Sets(X, Y, Z, W float32)

func (*Quat) Slerp

func (q *Quat) Slerp(q1 Quat, q2 Quat, delta float32)

func (Quat) Sub

func (q Quat) Sub(subtrahend Quat, out *Quat)

func (*Quat) ToMatrix

func (q *Quat) ToMatrix(m Matrix4f)

type Range

type Range[A Attr[A]] struct {
	Min A
	Max A
}

func (Range[A]) At

func (r Range[A]) At(delta float32) A

func (Range[A]) Random

func (r Range[A]) Random(rnd rand.Rand) A

type RenderTarget

type RenderTarget interface {
	Size() geom.Vec2i
	Texture() *Texture
	Window() *Window
}

type Round

type Round[A Attr[A]] struct {
	Center A
	Radius float32
}

func (Round[A]) PlaneSign

func (round Round[A]) PlaneSign(plane Plane[A]) PlaneSign

type Scalar

type Scalar[D Numeric] struct {
	Value D
}

func (Scalar[D]) Add

func (s Scalar[D]) Add(addend Scalar[D], out *Scalar[D])

func (Scalar[D]) AddScaled

func (s Scalar[D]) AddScaled(value Scalar[D], scale float32, out *Scalar[D])

func (Scalar[D]) Components

func (s Scalar[D]) Components() int

func (Scalar[D]) Distance

func (s Scalar[D]) Distance(value Scalar[D]) float32

func (Scalar[D]) DistanceSq

func (s Scalar[D]) DistanceSq(value Scalar[D]) float32

func (Scalar[D]) Div

func (s Scalar[D]) Div(factor Scalar[D], out *Scalar[D])

func (Scalar[D]) Dot

func (s Scalar[D]) Dot(value Scalar[D]) float32

func (Scalar[D]) GetComponent

func (s Scalar[D]) GetComponent(index int) float32

func (Scalar[D]) Length

func (s Scalar[D]) Length() float32

func (Scalar[D]) LengthSq

func (s Scalar[D]) LengthSq() float32

func (Scalar[D]) Lerp

func (start Scalar[D]) Lerp(end Scalar[D], delta float32, out *Scalar[D])

func (Scalar[D]) Mul

func (s Scalar[D]) Mul(factor Scalar[D], out *Scalar[D])

func (Scalar[D]) Scale

func (s Scalar[D]) Scale(scale float32, out *Scalar[D])

func (Scalar[D]) Set

func (s Scalar[D]) Set(out *Scalar[D])

func (Scalar[D]) SetComponent

func (s Scalar[D]) SetComponent(index int, value float32, out *Scalar[D])

func (Scalar[D]) SetComponents

func (s Scalar[D]) SetComponents(value float32, out *Scalar[D])

func (Scalar[D]) Sub

func (s Scalar[D]) Sub(subtrahend Scalar[D], out *Scalar[D])

type Scalarf

type Scalarf = Scalar[float32]

type Scalari

type Scalari = Scalar[int]

type Scene

type Scene[A Attr[A]] struct {
	Name   string
	Jobs   *job.JobRunner
	World  *World
	Space  Space[A, SpaceComponent[A]]
	Enable func(scene *Scene[A], game *Game)
	Load   func(scene *Scene[A], game *Game)
}

func (*Scene[A]) Destroy

func (scene *Scene[A]) Destroy()

func (*Scene[A]) Init

func (scene *Scene[A]) Init(game *Game) error

func (*Scene[A]) Update

func (scene *Scene[A]) Update(game *Game)

type Scene2f

type Scene2f = Scene[Vec2f]

type Scene3f

type Scene3f = Scene[Vec3f]

type Screen

type Screen interface {
	Size() geom.Vec2i
	Position() geom.Vec2i
}

type Segment

type Segment[A Attr[A]] struct {
	Start A
	End   A
}

type Shape

type Shape[A Attr[A]] interface {
	Finite() bool
	Distance(point A) float32
	Normal(point A, out *A) bool
	Raytrace(point A, direction A) bool
	Bounds(bounds *Bounds[A]) bool
	Round(round *Round[A]) bool
	PlaneSign(plane Plane[A]) PlaneSign
	Transform(shapeTransform Trans[A]) Shape[A]
}

type Space

type Space[A Attr[A], E any] interface {
	GameSystem

	Collisions(flags util.Match[SpaceFlags], callback SpaceCollisionCallback[E])
	Intersects(query SpaceQuery[A], callback SpaceSearchCallback[A, E]) int
	Contains(query SpaceQuery[A], callback SpaceSearchCallback[A, E]) int
	Raytrace(query SpaceQuery[A], callback SpaceSearchCallback[A, E]) int
	KNN(query SpaceQuery[A], nearest []SpaceNearest[E], nearestCount *int)
}

type SpaceCollisionCallback

type SpaceCollisionCallback[E any] func(subject E, otherSubject E, overlap float32, index int, second bool)

type SpaceComponent

type SpaceComponent[A Attr[A]] struct {
	Shape          Shape[A]
	Offset         A
	WorldTransform *Matrix[A]
	Flags          SpaceFlags
	Static         bool
	Inert          bool
}

type SpaceCoord

type SpaceCoord interface {
	To2d() (x, y float32)
	To3d() (x, y, z float32)
}

type SpaceFlags

type SpaceFlags uint64

type SpaceNearest

type SpaceNearest[E any] struct {
	Entity   E
	Distance float32
}

type SpaceQuery

type SpaceQuery[A Attr[A]] struct {
	Point   A
	End     A
	Shape   Shape[A]
	Maximum int
	Flags   util.Match[SpaceFlags]
}

type SpaceSearchCallback

type SpaceSearchCallback[A Attr[A], E any] func(entity E, overlap float32, index int, query SpaceQuery[A]) bool

type Sphere

type Sphere = Round[Vec3f]

type Stage

type Stage struct {
	Name    string
	Assets  []asset.Ref
	Windows []StageWindow
	Scenes2 []Scene2f
	Scenes3 []Scene3f
	Views2  []View2f
	Views3  []View3f
	Actions input.ActionSets
	// contains filtered or unexported fields
}

func (*Stage) GetScene2f

func (stage *Stage) GetScene2f(name string) *Scene2f

func (*Stage) GetScene3f

func (stage *Stage) GetScene3f(name string) *Scene3f

func (Stage) HasStartedLoading

func (stage Stage) HasStartedLoading() bool

func (*Stage) IsLoaded

func (stage *Stage) IsLoaded() bool

func (*Stage) Load

func (stage *Stage) Load(game *Game)

func (*Stage) Start

func (stage *Stage) Start(game *Game)

func (*Stage) Unload

func (stage *Stage) Unload(activeStage *Stage)

func (*Stage) Update

func (stage *Stage) Update(game *Game)

type StageManager

type StageManager struct {
	Stages  map[string]*Stage
	Current *Stage
	Next    *Stage
	// contains filtered or unexported fields
}

func NewStageManager

func NewStageManager() StageManager

func (*StageManager) Add

func (sm *StageManager) Add(stage *Stage)

func (*StageManager) Destroy

func (sm *StageManager) Destroy()

func (*StageManager) Events

func (*StageManager) Get

func (sm *StageManager) Get(name string) *Stage

func (*StageManager) GetStage

func (sm *StageManager) GetStage(game *Game) *Stage

func (*StageManager) Init

func (sm *StageManager) Init(game *Game) error

func (*StageManager) Set

func (sm *StageManager) Set(name string) bool

func (*StageManager) Update

func (sm *StageManager) Update(game *Game)

type StageManagerEvents

type StageManagerEvents struct {
	StageStarting func(current *Stage)
	StageStarted  func(current *Stage)
	StageExiting  func(current *Stage, next *Stage)
	StageExited   func(previous *Stage, current *Stage)
}

type StageWindow

type StageWindow struct {
	Name       string
	Title      string
	Placement  ui.Placement
	ClearColor color.Color
	Mode       WindowMode
	Screen     int
}

type StatDatabase

type StatDatabase struct {
	Name    string
	Updated time.Time
	Visible bool
	Event   *DebugEvent
	Enabled bool
	Sets    []StatSet
}

type StatPoint

type StatPoint struct {
	Total int
	Sum   float64
	Min   float64
	Max   float64
}

type StatSet

type StatSet struct {
	Index        int
	Description  string
	Interval     time.Duration
	PointerTime  time.Time
	PointerIndex int
	Points       []StatPoint
}

type Tag

type Tag string

type Texture

type Texture interface {
	Asset() *asset.Asset
	Width() int
	Height() int
}

type TextureColor

type TextureColor struct {
	Texture string
	Color   [3]float32
}

type TextureCoord

type TextureCoord struct {
	U float32
	V float32
}

type TextureFilter

type TextureFilter int
const (
	TextureFilterLinear TextureFilter = iota
	TextureFilterNearest
)

func (TextureFilter) Ptr

func (tf TextureFilter) Ptr() *TextureFilter

type TextureSettings

type TextureSettings struct {
	Min    TextureFilter
	Max    TextureFilter
	MipMap *TextureFilter
	WrapX  TextureWrap
	WrapY  TextureWrap
}

type TextureWrap

type TextureWrap int
const (
	TextureWrapRepeat TextureWrap = iota
	TextureWrapClampToEdge
	TextureWrapClampToBorder
	TextureWrapMirrorRepeat
)

type Tile

type Tile struct {
	Texture Texture
	Name    string
	Coord0  TextureCoord
	Coord1  TextureCoord
}

func NewTile

func NewTile(tex Texture) Tile

func (*Tile) Rect

func (t *Tile) Rect(x, y, w, h int32) Tile

func (*Tile) Rects

func (t *Tile) Rects(w, h int32, pos []geom.Vec2i) Tiles

func (*Tile) RectsGrid

func (t *Tile) RectsGrid(x, y, w, h, columns, rows int32) Tiles

type Tiles

type Tiles []Tile

func (*Tiles) Add

func (t *Tiles) Add(tile Tile)

func (*Tiles) AddTiles

func (t *Tiles) AddTiles(tiles Tiles)

func (Tiles) Textures

func (tiles Tiles) Textures() []Texture

type Time

type Time struct {
	Name        string
	DayDuration time.Duration
	Enabled     bool
	Scale       float32
	DateTime    time.Time
	Elapsed     time.Duration
	StartTime   time.Time
	// contains filtered or unexported fields
}

func NewTime

func NewTime(name string) Time

func (*Time) ElapsedScaled

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

func (*Time) Pause

func (t *Time) Pause()

func (*Time) Resume

func (t *Time) Resume()

func (*Time) ToTimeNow

func (t *Time) ToTimeNow(now time.Time) time.Time

func (*Time) Update

func (t *Time) Update()

type TimeType

type TimeType uint8
const (
	TimeTypeReal TimeType = iota
	TimeTypeWorld
)

type Timer

type Timer struct {
	LastTick  time.Time
	Current   time.Time
	Elapsed   time.Duration
	Frequency time.Duration
	Ticks     int64
}

func (*Timer) NextTick

func (e *Timer) NextTick() time.Duration

func (*Timer) Reset

func (e *Timer) Reset()

func (*Timer) Tick

func (e *Timer) Tick() bool

type Trans

type Trans[A Attr[A]] interface {
	GetScale() A
	GetPosition() A
	ToMatrix(m []float32)
	Transform(v A) A
	TransformVector(v A) A
}

type Trans2d

type Trans2d struct {
	Scale    Vec2d
	Position Vec2d
	Rotation Vec2d
}

func (Trans2d) GetPosition

func (t Trans2d) GetPosition() Vec2d

func (Trans2d) GetScale

func (t Trans2d) GetScale() Vec2d

func (Trans2d) ToMatrix

func (t Trans2d) ToMatrix(m []float32)

func (Trans2d) Transform

func (t Trans2d) Transform(v Vec2d) Vec2d

func (Trans2d) TransformVector

func (t Trans2d) TransformVector(v Vec2d) Vec2d

type Trans3d

type Trans3d struct {
	Scale    Vec3d
	Position Vec3d
	Rotation Quat
}

func (Trans3d) GetPosition

func (t Trans3d) GetPosition() Vec3d

func (Trans3d) GetScale

func (t Trans3d) GetScale() Vec3d

func (Trans3d) ToMatrix

func (t Trans3d) ToMatrix(m []float32)

func (Trans3d) Transform

func (t Trans3d) Transform(v Vec3d) Vec3d

func (Trans3d) TransformVector

func (t Trans3d) TransformVector(v Vec3d) Vec3d

type Transform

type Transform[A Attr[A]] struct {
	Tree ecs.Tree
	// contains filtered or unexported fields
}

func NewTransform

func NewTransform[A Attr[A]](create TransformCreate[A]) Transform[A]

func (*Transform[A]) GetPosition

func (t *Transform[A]) GetPosition() A

func (*Transform[A]) GetRotation

func (t *Transform[A]) GetRotation() A

func (*Transform[A]) GetScale

func (t *Transform[A]) GetScale() A

func (Transform[A]) IsDirty

func (t Transform[A]) IsDirty() bool

func (*Transform[A]) Local

func (t *Transform[A]) Local() Matrix[A]

func (*Transform[A]) SetLocal

func (t *Transform[A]) SetLocal(local Matrix[A])

func (*Transform[A]) SetParent

func (t *Transform[A]) SetParent(parent *ecs.Entity)

func (*Transform[A]) SetPosition

func (t *Transform[A]) SetPosition(position A)

func (*Transform[A]) SetRotation

func (t *Transform[A]) SetRotation(rotation A)

func (*Transform[A]) SetScale

func (t *Transform[A]) SetScale(scale A)

func (*Transform[A]) Update

func (t *Transform[A]) Update(updateWorld bool)

func (*Transform[A]) World

func (t *Transform[A]) World() Matrix[A]

type Transform2f

type Transform2f = Transform[Vec2f]

func NewTransform2

func NewTransform2(create TransformCreate2f) Transform2f

type Transform3f

type Transform3f = Transform[Vec3f]

func NewTransform3

func NewTransform3(create TransformCreate3f) Transform3f

type Transform4f

type Transform4f = Transform[Vec4f]

func NewTransform4

func NewTransform4(create TransformCreate4f) Transform4f

type TransformCreate

type TransformCreate[A Attr[A]] struct {
	Position A
	Rotation A
	Scale    A
}

type TransformCreate2f

type TransformCreate2f = TransformCreate[Vec2f]

type TransformCreate3f

type TransformCreate3f = TransformCreate[Vec3f]

type TransformCreate4f

type TransformCreate4f = TransformCreate[Vec4f]

type TransformSystem

type TransformSystem[A Attr[A]] struct{}

func (*TransformSystem[A]) Destroy

func (sys *TransformSystem[A]) Destroy(ctx ecs.Context)

func (*TransformSystem[A]) Init

func (sys *TransformSystem[A]) Init(ctx ecs.Context) error

func (*TransformSystem[A]) OnLive

func (sys *TransformSystem[A]) OnLive(data *Transform[A], e *ecs.Entity, ctx ecs.Context)

func (*TransformSystem[A]) OnRemove

func (sys *TransformSystem[A]) OnRemove(data *Transform[A], e *ecs.Entity, ctx ecs.Context)

func (*TransformSystem[A]) OnStage

func (sys *TransformSystem[A]) OnStage(data *Transform[A], e *ecs.Entity, ctx ecs.Context)

func (*TransformSystem[A]) Update

func (sys *TransformSystem[A]) Update(iter ds.Iterable[ecs.Value[*Transform[A]]], ctx ecs.Context)

type Tween

type Tween[T Attr[T]] struct {
	Start AnimValue[T]
	End   AnimValue[T]
}

func (Tween[T]) Flags

func (path Tween[T]) Flags() PathFlag

func (Tween[T]) Point

func (path Tween[T]) Point(index int) AnimValue[T]

func (Tween[T]) PointCount

func (path Tween[T]) PointCount() int

func (Tween[T]) Set

func (path Tween[T]) Set(out *T, delta float32)

type UserInterface

type UserInterface struct {
	*ui.UI
}

func NewUserInterface

func NewUserInterface() UserInterface

type UserInterfaceSystem

type UserInterfaceSystem struct{}

func (UserInterfaceSystem) Destroy

func (sys UserInterfaceSystem) Destroy(ctx ecs.Context)

func (UserInterfaceSystem) Init

func (sys UserInterfaceSystem) Init(ctx ecs.Context) error

func (UserInterfaceSystem) OnLive

func (sys UserInterfaceSystem) OnLive(data *UserInterface, e *ecs.Entity, ctx ecs.Context)

func (UserInterfaceSystem) OnRemove

func (sys UserInterfaceSystem) OnRemove(data *UserInterface, e *ecs.Entity, ctx ecs.Context)

func (UserInterfaceSystem) OnStage

func (sys UserInterfaceSystem) OnStage(data *UserInterface, e *ecs.Entity, ctx ecs.Context)

func (UserInterfaceSystem) Update

func (sys UserInterfaceSystem) Update(iter ds.Iterable[ecs.Value[*UserInterface]], ctx ecs.Context)

type Vec2

type Vec2[D Numeric] struct {
	X D
	Y D
}

func (Vec2[D]) Add

func (v Vec2[D]) Add(value Vec2[D], out *Vec2[D])

func (Vec2[D]) AddScaled

func (v Vec2[D]) AddScaled(value Vec2[D], scale float32, out *Vec2[D])

func (Vec2[D]) Components

func (v Vec2[D]) Components() int

func (Vec2[D]) Distance

func (v Vec2[D]) Distance(value Vec2[D]) float32

func (Vec2[D]) DistanceSq

func (v Vec2[D]) DistanceSq(a Vec2[D]) float32

func (Vec2[D]) Div

func (v Vec2[D]) Div(factor Vec2[D], out *Vec2[D])

func (Vec2[D]) Dot

func (v Vec2[D]) Dot(a Vec2[D]) float32

func (Vec2[D]) GetComponent

func (v Vec2[D]) GetComponent(index int) float32

func (Vec2[D]) Length

func (v Vec2[D]) Length() float32

func (Vec2[D]) LengthSq

func (v Vec2[D]) LengthSq() float32

func (Vec2[D]) Lerp

func (start Vec2[D]) Lerp(end Vec2[D], delta float32, out *Vec2[D])

func (Vec2[D]) Mul

func (v Vec2[D]) Mul(factor Vec2[D], out *Vec2[D])

func (Vec2[D]) Scale

func (v Vec2[D]) Scale(amount float32, out *Vec2[D])

func (Vec2[D]) Set

func (v Vec2[D]) Set(out *Vec2[D])

func (Vec2[D]) SetComponent

func (v Vec2[D]) SetComponent(index int, value float32, out *Vec2[D])

func (Vec2[D]) SetComponents

func (v Vec2[D]) SetComponents(value float32, out *Vec2[D])

func (*Vec2[D]) SetDegrees

func (v *Vec2[D]) SetDegrees(deg float32, len float32)

func (*Vec2[D]) SetRadians

func (v *Vec2[D]) SetRadians(rad float32, len float32)

func (Vec2[D]) Sub

func (v Vec2[D]) Sub(value Vec2[D], out *Vec2[D])

func (Vec2[D]) To2d

func (v Vec2[D]) To2d() (x, y float32)

func (Vec2[D]) To3d

func (v Vec2[D]) To3d() (x, y, z float32)

type Vec2d

type Vec2d = Vec2[float32]

type Vec2f

type Vec2f = Vec2[float32]

type Vec2i

type Vec2i = Vec2[int]

type Vec3

type Vec3[D Numeric] struct {
	X D
	Y D
	Z D
}

func (Vec3[D]) Add

func (v Vec3[D]) Add(value Vec3[D], out *Vec3[D])

func (Vec3[D]) AddScaled

func (v Vec3[D]) AddScaled(value Vec3[D], scale float32, out *Vec3[D])

func (Vec3[D]) Components

func (v Vec3[D]) Components() int

func (Vec3[D]) Cross

func (v Vec3[D]) Cross(other Vec3[D], out *Vec3[D])

func (Vec3[D]) Distance

func (v Vec3[D]) Distance(value Vec3[D]) float32

func (Vec3[D]) DistanceSq

func (v Vec3[D]) DistanceSq(value Vec3[D]) float32

func (Vec3[D]) Div

func (v Vec3[D]) Div(value Vec3[D], out *Vec3[D])

func (Vec3[D]) Dot

func (v Vec3[D]) Dot(a Vec3[D]) float32

func (Vec3[D]) GetComponent

func (v Vec3[D]) GetComponent(index int) float32

func (Vec3[D]) Length

func (v Vec3[D]) Length() float32

func (Vec3[D]) LengthSq

func (v Vec3[D]) LengthSq() float32

func (Vec3[D]) Lerp

func (start Vec3[D]) Lerp(end Vec3[D], delta float32, out *Vec3[D])

func (Vec3[D]) Mul

func (v Vec3[D]) Mul(value Vec3[D], out *Vec3[D])

func (Vec3[D]) Normal

func (v Vec3[D]) Normal(out *Vec3[D]) float32

func (Vec3[D]) Scale

func (v Vec3[D]) Scale(amount float32, out *Vec3[D])

func (Vec3[D]) Set

func (v Vec3[D]) Set(out *Vec3[D])

func (Vec3[D]) SetComponent

func (v Vec3[D]) SetComponent(index int, value float32, out *Vec3[D])

func (Vec3[D]) SetComponents

func (v Vec3[D]) SetComponents(value float32, out *Vec3[D])

func (Vec3[D]) Sub

func (v Vec3[D]) Sub(value Vec3[D], out *Vec3[D])

func (Vec3[D]) To2d

func (v Vec3[D]) To2d() (x, y float32)

func (Vec3[D]) To3d

func (v Vec3[D]) To3d() (x, y, z float32)

type Vec3d

type Vec3d = Vec4[float32]

type Vec3f

type Vec3f = Vec3[float32]

type Vec3i

type Vec3i = Vec3[int]

type Vec4

type Vec4[D Numeric] struct {
	X D
	Y D
	Z D
	W D
}

func (Vec4[D]) Add

func (v Vec4[D]) Add(value Vec4[D], out *Vec4[D])

func (Vec4[D]) AddScaled

func (v Vec4[D]) AddScaled(value Vec4[D], scale float32, out *Vec4[D])

func (Vec4[D]) Components

func (v Vec4[D]) Components() int

func (Vec4[D]) Cross

func (v Vec4[D]) Cross(other Vec4[D], out *Vec4[D])

func (Vec4[D]) Distance

func (v Vec4[D]) Distance(value Vec4[D]) float32

func (Vec4[D]) DistanceSq

func (v Vec4[D]) DistanceSq(value Vec4[D]) float32

func (Vec4[D]) Div

func (v Vec4[D]) Div(value Vec4[D], out *Vec4[D])

func (Vec4[D]) Dot

func (v Vec4[D]) Dot(a Vec4[D]) float32

func (Vec4[D]) GetComponent

func (v Vec4[D]) GetComponent(index int) float32

func (Vec4[D]) Length

func (v Vec4[D]) Length() float32

func (Vec4[D]) LengthSq

func (v Vec4[D]) LengthSq() float32

func (Vec4[D]) Lerp

func (start Vec4[D]) Lerp(end Vec4[D], delta float32, out *Vec4[D])

func (Vec4[D]) Mul

func (v Vec4[D]) Mul(value Vec4[D], out *Vec4[D])

func (Vec4[D]) Scale

func (v Vec4[D]) Scale(amount float32, out *Vec4[D])

func (Vec4[D]) Set

func (v Vec4[D]) Set(out *Vec4[D])

func (Vec4[D]) SetComponent

func (v Vec4[D]) SetComponent(index int, value float32, out *Vec4[D])

func (Vec4[D]) SetComponents

func (v Vec4[D]) SetComponents(value float32, out *Vec4[D])

func (Vec4[D]) Sub

func (v Vec4[D]) Sub(value Vec4[D], out *Vec4[D])

func (Vec4[D]) To2d

func (v Vec4[D]) To2d() (x, y float32)

func (Vec4[D]) To3d

func (v Vec4[D]) To3d() (x, y, z float32)

type Vec4f

type Vec4f = Vec4[float32]

type Vec4i

type Vec4i = Vec4[int]

type View

type View[A Attr[A]] interface {
	GameSystem

	Name() string
	Scene() Scene[A]
	Camera() Camera[A]
	ProjectionMatrix() Matrix[A]
	ViewMatrix() Matrix[A]
	CombinedMatrix() Matrix[A]
	ProjectPoint(mouse geom.Vec2i, outside ProjectionOutside) A
	Project(outside ProjectionOutside) A
	ProjectIgnore() A
	UnprojectPoint(point A, outside ProjectionOutside) A
	UnprojectIgnore(point A) A
	Placement() ui.Placement
	Target() RenderTarget
}

type View2f

type View2f struct {
	Name             string
	SceneName        string
	Camera           Camera2d
	ProjectionMatrix Matrix2f
	ViewMatrix       Matrix2f
	CombinedMatrix   Matrix2f
	Placement        ui.Placement
	Target           RenderTarget

	OnInit    func(view *View2f, game *Game)
	OnUpdate  func(view *View2f, game *Game)
	OnDestroy func(view *View2f)
	// contains filtered or unexported fields
}

func (*View2f) Destroy

func (v *View2f) Destroy()

func (*View2f) Init

func (v *View2f) Init(game *Game) error

func (View2f) Project

func (v View2f) Project(outside ProjectionOutside) Vec2f

func (View2f) ProjectIgnore

func (v View2f) ProjectIgnore() Vec2f

func (View2f) ProjectPoint

func (v View2f) ProjectPoint(mouse geom.Vec2i, outside ProjectionOutside) Vec2f

func (View2f) Scene

func (v View2f) Scene() *Scene2f

func (View2f) UnprojectIgnore

func (v View2f) UnprojectIgnore(point Vec2f) Vec2f

func (View2f) UnprojectPoint

func (v View2f) UnprojectPoint(point Vec2f, outside ProjectionOutside) Vec2f

func (*View2f) Update

func (v *View2f) Update(game *Game)

type View3f

type View3f struct {
	Name             string
	SceneName        string
	Camera           Camera3d
	ProjectionMatrix Matrix4f
	ViewMatrix       Matrix4f
	CombinedMatrix   Matrix4f
	Placement        ui.Placement
	Target           RenderTarget

	OnInit    func(view *View3f, game *Game)
	OnUpdate  func(view *View3f, game *Game)
	OnDestroy func(view *View3f)
	// contains filtered or unexported fields
}

func (*View3f) Destroy

func (v *View3f) Destroy()

func (*View3f) Init

func (v *View3f) Init(game *Game) error

func (View3f) Project

func (v View3f) Project(outside ProjectionOutside) Vec3f

func (View3f) ProjectIgnore

func (v View3f) ProjectIgnore() Vec3f

func (View3f) ProjectPoint

func (v View3f) ProjectPoint(mouse geom.Vec2i, outside ProjectionOutside) Vec3f

func (View3f) Scene

func (v View3f) Scene() *Scene3f

func (View3f) UnprojectIgnore

func (v View3f) UnprojectIgnore(point Vec3f) Vec3f

func (View3f) UnprojectPoint

func (v View3f) UnprojectPoint(point Vec3f, outside ProjectionOutside) Vec3f

func (*View3f) Update

func (v *View3f) Update(game *Game)

type Watched

type Watched[V any] struct {
	Changed bool
	// contains filtered or unexported fields
}

func (*Watched[V]) Get

func (w *Watched[V]) Get() V

func (*Watched[V]) Ptr

func (w *Watched[V]) Ptr() *V

func (*Watched[V]) Set

func (w *Watched[V]) Set(value V)

type Window

type Window interface {
	Name() string
	Title() react.Value[string]
	Placement() ui.Placement
	Screen() Screen
	Size() geom.Vec2i
}

type WindowMode

type WindowMode int
const (
	WindowModeResizable WindowMode = iota
	WindowModeFixed
	WindowModeBorderless
	WindowModeFullscreen
)

type WindowSystem

type WindowSystem interface {
	GameSystem
	MainWindow() Window
	Windows() []Window
	Screens() []Screen
	Events() *core.Listeners[WindowSystemEvents]
}

type WindowSystemEvents

type WindowSystemEvents struct {
	MouseScreenChange  func(oldMouse geom.Vec2i, oldScreen Screen, newMouse geom.Vec2i, newScreen Screen)
	ScreenConnected    func(newScreen Screen)
	ScreenDisconnected func(oldScreen Screen)
	ScreenResize       func(screen Screen, oldSize geom.Vec2i, newSize geom.Vec2i)
	WindowResize       func(window Window, oldSize geom.Vec2i, newSize geom.Vec2i)
	WindowAdded        func(window Window)
	WindowRemoved      func(window Window)
}

type World

type World struct {
	ecs.World
}

func NewWorld

func NewWorld(name string, settings ecs.WorldSettings) *World

func (*World) Init

func (w *World) Init(game *Game) error

func (*World) Update

func (w *World) Update(game *Game)

Directories

Path Synopsis
ai
Possible features
Possible features
impl
The steer package contains steering behaviors for autonomous movement.
The steer package contains steering behaviors for autonomous movement.
ui
ua
ux
ux is a package that supplies basic components built on the ui package.
ux is a package that supplies basic components built on the ui package.

Jump to

Keyboard shortcuts

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