Documentation
¶
Index ¶
- Variables
- func BindDefault3DControls()
- func ConnectEntitySignal(entityID uint64, name string, cb func(...any)) uint64
- func ConnectEntitySignal1[A any](entityID uint64, name string, cb func(A)) uint64
- func ConnectEntitySignal2[A, B any](entityID uint64, name string, cb func(A, B)) uint64
- func ConnectGlobalSignal(name string, cb func(...any)) uint64
- func ConnectGlobalSignal1[A any](name string, cb func(A)) uint64
- func ConnectGlobalSignal2[A, B any](name string, cb func(A, B)) uint64
- func ConnectScopedSignal(scope SignalScope, owner, name string, cb func(...any)) uint64
- func ConnectSystemSignal(system, name string, cb func(...any)) uint64
- func ConnectSystemSignal0(system, name string, cb func()) uint64
- func ConnectSystemSignal1[A any](system, name string, cb func(A)) uint64
- func ConnectSystemSignal2[A, B any](system, name string, cb func(A, B)) uint64
- func ConnectSystemSignal3[A, B, C any](system, name string, cb func(A, B, C)) uint64
- func DisconnectEntitySignal(entityID uint64, name string, id uint64)
- func DisconnectGlobalSignal(name string, id uint64)
- func DisconnectScopedSignal(scope SignalScope, owner, name string, id uint64)
- func DisconnectSystemSignal(system, name string, id uint64)
- func EmitEntitySignal(entityID uint64, name string, args ...any)
- func EmitEntitySignalDeferred(entityID uint64, name string, args ...any)
- func EmitGlobalSignal(name string, args ...any)
- func EmitGlobalSignalDeferred(name string, args ...any)
- func EmitScopedSignal(scope SignalScope, owner, name string, args ...any)
- func EmitScopedSignalDeferred(scope SignalScope, owner, name string, args ...any)
- func EmitSystemSignal(system, name string, args ...any)
- func EmitSystemSignalDeferred(system, name string, args ...any)
- func FlushDeferredSignals()
- func ListEntitySignals(entityID uint64) []string
- func ListGlobalSignals() []string
- func ListSignals(scope SignalScope, owner string) []string
- func ListSystemSignals(system string) []string
- func RemoveEntitySignals(entityID uint64)
- type AssetManager
- func (a *AssetManager) ClearCache()
- func (a *AssetManager) Exists(name string) bool
- func (a *AssetManager) MustResolve(name string) string
- func (a *AssetManager) Open(name string) (*os.File, error)
- func (a *AssetManager) ReadBytes(name string) ([]byte, error)
- func (a *AssetManager) ReadString(name string) (string, error)
- func (a *AssetManager) Register(name, path string) error
- func (a *AssetManager) Resolve(name string) (string, error)
- func (a *AssetManager) Root() string
- type DeferredEmission
- type InputManager
- func (i *InputManager) BeginFrame()
- func (i *InputManager) BindAction(action string, keys ...sdl.Scancode)
- func (i *InputManager) BufferAction(action string)
- func (i *InputManager) EnqueueEvent(event sdl.Event)
- func (i *InputManager) HasBufferedAction(action string) bool
- func (i *InputManager) IsActionJustPressed(action string) bool
- func (i *InputManager) IsActionJustReleased(action string) bool
- func (i *InputManager) IsActionPressed(action string) bool
- func (i *InputManager) IsKeyJustPressed(key sdl.Scancode) bool
- func (i *InputManager) IsKeyJustReleased(key sdl.Scancode) bool
- func (i *InputManager) IsKeyPressed(key sdl.Scancode) bool
- func (i *InputManager) OnEvent(cb func(sdl.Event)) func()
- func (i *InputManager) ProcessEvent(event sdl.Event)
- func (i *InputManager) Start()
- func (i *InputManager) Stop()
- func (i *InputManager) UnbindAction(action string)
- func (i *InputManager) UpdateBuffers(dt float32)
- type Node3D
- func (n *Node3D) At(x, y, z float32) *Node3D
- func (n *Node3D) Build() ecs.Entity
- func (n *Node3D) Sized(x, y, z float32) *Node3D
- func (n *Node3D) WithCamera(camera components.Camera3D) *Node3D
- func (n *Node3D) WithCharacterBody(body components.CharacterBody3D) *Node3D
- func (n *Node3D) WithMaterial(material components.Material3D) *Node3D
- func (n *Node3D) WithMesh(mesh components.Mesh3D) *Node3D
- func (n *Node3D) WithRigidBody(body components.RigidBody3D) *Node3D
- func (n *Node3D) WithStaticBody() *Node3D
- type Scene
- func (s *Scene) AddCharacterBody3D(entity ecs.Entity, body components.CharacterBody3D)
- func (s *Scene) AddEntityCallbacks(entity ecs.Entity, start func(*ecs.World, ecs.Entity), ...)
- func (s *Scene) AddMaterial3D(entity ecs.Entity, material components.Material3D)
- func (s *Scene) AddMesh3D(entity ecs.Entity, mesh components.Mesh3D)
- func (s *Scene) AddPhysicsCallback(entity ecs.Entity, cb func(*ecs.World, ecs.Entity, float32))
- func (s *Scene) AddProcessCallback(entity ecs.Entity, cb func(*ecs.World, ecs.Entity, float32))
- func (s *Scene) AddRigidBody3D(entity ecs.Entity, body components.RigidBody3D)
- func (s *Scene) AddStartCallback(entity ecs.Entity, cb func(*ecs.World, ecs.Entity))
- func (s *Scene) AddStaticBody3D(entity ecs.Entity)
- func (s *Scene) AddTransform3D(entity ecs.Entity, t components.Transform3D)
- func (s *Scene) CreateBox3D(width, height, depth float32, material components.Material3D) ecs.Entity
- func (s *Scene) CreateCamera3D(camera components.Camera3D) ecs.Entity
- func (s *Scene) CreateCube3D(size float32, material components.Material3D) ecs.Entity
- func (s *Scene) CreateEntity() ecs.Entity
- func (s *Scene) CreateEntity3D() ecs.Entity
- func (s *Scene) CreatePlane3D(width, depth float32, material components.Material3D) ecs.Entity
- func (s *Scene) DestroyEntity(entity ecs.Entity)
- func (s *Scene) GetCamera() ecs.Entity
- func (s *Scene) RegisterPhysicsSystem(sys interface{ ... })
- func (s *Scene) RegisterProcessSystem(sys interface{ ... })
- func (s *Scene) SetCamera(entity ecs.Entity)
- func (s *Scene) SetDefaultCamera() ecs.Entity
- func (s *Scene) StartProcessing(win *Window)
- func (s *Scene) World() *ecs.World
- type Scene3D
- func (s *Scene3D) CameraEntity() ecs.Entity
- func (s *Scene3D) SetCamera(entity ecs.Entity)
- func (s *Scene3D) Spawn() *Node3D
- func (s *Scene3D) SpawnBox(width, height, depth float32) *Node3D
- func (s *Scene3D) SpawnCamera() *Node3D
- func (s *Scene3D) SpawnCube(size float32) *Node3D
- func (s *Scene3D) SpawnPlane(width, depth float32) *Node3D
- func (s *Scene3D) World() *ecs.World
- type ScreenType
- type Signal
- func GetEntitySignal(entityID uint64, name string) *Signal
- func GetGlobalSignal(name string) *Signal
- func GetScopedSignal(scope SignalScope, owner, name string) *Signal
- func GetSystemSignal(system, name string) *Signal
- func NewSignal() *Signal
- func RegisterEntitySignal(entityID uint64, name string) *Signal
- func RegisterEntitySignalDef(entityID uint64, def *SignalDef) *Signal
- func RegisterGlobalSignal(name string) *Signal
- func RegisterGlobalSignalDef(def *SignalDef) *Signal
- func RegisterScopedSignal(scope SignalScope, owner, name string) *Signal
- func RegisterScopedSignalDef(scope SignalScope, owner string, def *SignalDef) *Signal
- func RegisterSystemSignal(system, name string) *Signal
- func RegisterSystemSignalDef(system string, def *SignalDef) *Signal
- type SignalDef
- type SignalScope
- type Window
- func (w *Window) Destroy()
- func (w *Window) OnPhysicsProcess(cb func(dt float32))
- func (w *Window) OnProcess(cb func(dt float32))
- func (w *Window) OnReady(cb func())
- func (w *Window) Renderer() *sdl.Renderer
- func (w *Window) Run()
- func (w *Window) RunWithUpdate(update func())
- func (w *Window) ScreenType() ScreenType
- func (w *Window) SetClearColor(r, g, b, a uint8)
- func (w *Window) SetClearColorHex(hex string) error
- func (w *Window) SetPhysicsStep(step float32)
- func (w *Window) SetScreenType(screenType ScreenType, logicalW, logicalH int32) error
- func (w *Window) ViewportSize() (int32, int32)
Constants ¶
This section is empty.
Variables ¶
var DefaultAssets = NewAssetManager("assets")
DefaultAssets points at the conventional project assets directory.
var Input = NewInputManager()
Functions ¶
func BindDefault3DControls ¶ added in v0.1.7
func BindDefault3DControls()
BindDefault3DControls registers the standard movement controls used by 3D sample scenes.
func ConnectEntitySignal ¶
ConnectEntitySignal connects to an entity-scoped signal.
func ConnectEntitySignal1 ¶
ConnectEntitySignal1 connects a typed callback for one-argument entity signals.
func ConnectEntitySignal2 ¶
ConnectEntitySignal2 connects a typed callback for two-argument entity signals.
func ConnectGlobalSignal ¶
ConnectGlobalSignal connects to a global signal.
func ConnectGlobalSignal1 ¶
ConnectGlobalSignal1 connects a typed callback for one-argument global signals.
func ConnectGlobalSignal2 ¶
ConnectGlobalSignal2 connects a typed callback for two-argument global signals.
func ConnectScopedSignal ¶
func ConnectScopedSignal(scope SignalScope, owner, name string, cb func(...any)) uint64
ConnectScopedSignal registers (if needed) and connects a callback.
func ConnectSystemSignal ¶
ConnectSystemSignal is a convenience to register and connect in one call.
func ConnectSystemSignal0 ¶
ConnectSystemSignal0 connects a typed callback with no arguments.
func ConnectSystemSignal1 ¶
ConnectSystemSignal1 connects a typed callback for one argument system signals.
func ConnectSystemSignal2 ¶
ConnectSystemSignal2 connects a typed callback for two argument system signals.
func ConnectSystemSignal3 ¶
ConnectSystemSignal3 connects a typed callback for three argument system signals.
func DisconnectEntitySignal ¶
DisconnectEntitySignal disconnects from an entity-scoped signal by id.
func DisconnectGlobalSignal ¶
DisconnectGlobalSignal disconnects from a global signal by id.
func DisconnectScopedSignal ¶
func DisconnectScopedSignal(scope SignalScope, owner, name string, id uint64)
DisconnectScopedSignal disconnects a listener from scope/owner/name by id.
func DisconnectSystemSignal ¶
DisconnectSystemSignal removes a listener by id from a system signal.
func EmitEntitySignal ¶
EmitEntitySignal emits to an entity-scoped signal synchronously.
func EmitEntitySignalDeferred ¶
EmitEntitySignalDeferred queues an entity signal for emission at frame end.
func EmitGlobalSignal ¶
EmitGlobalSignal emits a global signal synchronously.
func EmitGlobalSignalDeferred ¶
EmitGlobalSignalDeferred queues a global signal for frame-end emission.
func EmitScopedSignal ¶
func EmitScopedSignal(scope SignalScope, owner, name string, args ...any)
EmitScopedSignal emits to all listeners under scope/owner/name synchronously.
func EmitScopedSignalDeferred ¶
func EmitScopedSignalDeferred(scope SignalScope, owner, name string, args ...any)
EmitScopedSignalDeferred queues a signal emission to execute at frame end via FlushDeferredSignals. This mirrors Godot's emit_deferred() and allows safer tree modifications.
func EmitSystemSignal ¶
EmitSystemSignal emits a system signal synchronously.
func EmitSystemSignalDeferred ¶
EmitSystemSignalDeferred queues a system signal for emission at frame end.
func FlushDeferredSignals ¶
func FlushDeferredSignals()
FlushDeferredSignals executes all queued deferred emissions. Call this at the end of each frame, typically in the game loop after all updates.
func ListEntitySignals ¶
ListEntitySignals returns all signal names for an entity.
func ListGlobalSignals ¶
func ListGlobalSignals() []string
ListGlobalSignals returns all global signal names.
func ListSignals ¶
func ListSignals(scope SignalScope, owner string) []string
ListSignals returns all signal names for a given scope/owner. Useful for introspection and discovering what signals a system emits.
func ListSystemSignals ¶
ListSystemSignals returns all signal names emitted by a system.
func RemoveEntitySignals ¶
func RemoveEntitySignals(entityID uint64)
RemoveEntitySignals cleans up all signals for a given entity (called on entity destruction). This prevents memory leaks and mimics Godot's automatic cleanup.
Types ¶
type AssetManager ¶ added in v0.1.7
type AssetManager struct {
// contains filtered or unexported fields
}
AssetManager resolves and caches project assets. It is intentionally file-oriented so it can support textures, audio, JSON, or any other asset type.
func NewAssetManager ¶ added in v0.1.7
func NewAssetManager(root string) *AssetManager
NewAssetManager creates a manager rooted at the given directory. If root is empty, it defaults to "assets".
func (*AssetManager) ClearCache ¶ added in v0.1.7
func (a *AssetManager) ClearCache()
ClearCache removes cached asset bytes.
func (*AssetManager) Exists ¶ added in v0.1.7
func (a *AssetManager) Exists(name string) bool
Exists reports whether the resolved asset path exists on disk.
func (*AssetManager) MustResolve ¶ added in v0.1.7
func (a *AssetManager) MustResolve(name string) string
MustResolve returns the resolved asset path or panics if the asset cannot be resolved.
func (*AssetManager) Open ¶ added in v0.1.7
func (a *AssetManager) Open(name string) (*os.File, error)
Open opens an asset for streaming access.
func (*AssetManager) ReadBytes ¶ added in v0.1.7
func (a *AssetManager) ReadBytes(name string) ([]byte, error)
ReadBytes loads an asset into memory and caches the contents by resolved path.
func (*AssetManager) ReadString ¶ added in v0.1.7
func (a *AssetManager) ReadString(name string) (string, error)
ReadString loads an asset as UTF-8 text.
func (*AssetManager) Register ¶ added in v0.1.7
func (a *AssetManager) Register(name, path string) error
Register associates a logical name with a relative or absolute path.
func (*AssetManager) Resolve ¶ added in v0.1.7
func (a *AssetManager) Resolve(name string) (string, error)
Resolve returns the absolute or project-relative path for a logical asset name. Registered aliases take precedence; otherwise the input is treated as a path under the asset root.
func (*AssetManager) Root ¶ added in v0.1.7
func (a *AssetManager) Root() string
Root returns the current asset root directory.
type DeferredEmission ¶
type DeferredEmission struct {
// contains filtered or unexported fields
}
DeferredEmission represents a signal emission queued for frame-end execution. This mirrors Godot's emit_deferred() pattern.
type InputManager ¶
type InputManager struct {
// contains filtered or unexported fields
}
func NewInputManager ¶
func NewInputManager() *InputManager
func (*InputManager) BeginFrame ¶
func (i *InputManager) BeginFrame()
BeginFrame clears edge-triggered state for the new frame.
func (*InputManager) BindAction ¶
func (i *InputManager) BindAction(action string, keys ...sdl.Scancode)
func (*InputManager) BufferAction ¶
func (i *InputManager) BufferAction(action string)
BufferAction adds an action to the input buffer (called when action is pressed).
func (*InputManager) EnqueueEvent ¶
func (i *InputManager) EnqueueEvent(event sdl.Event)
EnqueueEvent is non-blocking and safe to call from the main loop. If the queue is full, it processes the event inline instead of stalling.
func (*InputManager) HasBufferedAction ¶
func (i *InputManager) HasBufferedAction(action string) bool
HasBufferedAction checks if an action has a buffered input (consumes it).
func (*InputManager) IsActionJustPressed ¶
func (i *InputManager) IsActionJustPressed(action string) bool
func (*InputManager) IsActionJustReleased ¶
func (i *InputManager) IsActionJustReleased(action string) bool
func (*InputManager) IsActionPressed ¶
func (i *InputManager) IsActionPressed(action string) bool
func (*InputManager) IsKeyJustPressed ¶
func (i *InputManager) IsKeyJustPressed(key sdl.Scancode) bool
func (*InputManager) IsKeyJustReleased ¶
func (i *InputManager) IsKeyJustReleased(key sdl.Scancode) bool
func (*InputManager) IsKeyPressed ¶
func (i *InputManager) IsKeyPressed(key sdl.Scancode) bool
func (*InputManager) OnEvent ¶
func (i *InputManager) OnEvent(cb func(sdl.Event)) func()
OnEvent registers a callback that receives every SDL event seen by the input worker. It returns a function that unregisters the callback.
func (*InputManager) ProcessEvent ¶
func (i *InputManager) ProcessEvent(event sdl.Event)
func (*InputManager) Start ¶
func (i *InputManager) Start()
Start launches the background event worker. It is safe to call multiple times.
func (*InputManager) Stop ¶
func (i *InputManager) Stop()
Stop terminates the background event worker.
func (*InputManager) UnbindAction ¶
func (i *InputManager) UnbindAction(action string)
func (*InputManager) UpdateBuffers ¶
func (i *InputManager) UpdateBuffers(dt float32)
UpdateBuffers decays input buffer timers each frame (call from OnProcess, once per render frame).
type Node3D ¶ added in v0.1.7
type Node3D struct {
// contains filtered or unexported fields
}
Node3D is a fluent entity builder for reusable 3D setup.
func (*Node3D) Build ¶ added in v0.1.7
Build commits the node data into the ECS world and returns its entity id.
func (*Node3D) WithCamera ¶ added in v0.1.7
func (n *Node3D) WithCamera(camera components.Camera3D) *Node3D
WithCamera attaches a camera component to the node.
func (*Node3D) WithCharacterBody ¶ added in v0.1.7
func (n *Node3D) WithCharacterBody(body components.CharacterBody3D) *Node3D
WithCharacterBody attaches a 3D character body to the node.
func (*Node3D) WithMaterial ¶ added in v0.1.7
func (n *Node3D) WithMaterial(material components.Material3D) *Node3D
WithMaterial attaches a material to the node.
func (*Node3D) WithMesh ¶ added in v0.1.7
func (n *Node3D) WithMesh(mesh components.Mesh3D) *Node3D
WithMesh attaches a mesh to the node.
func (*Node3D) WithRigidBody ¶ added in v0.1.7
func (n *Node3D) WithRigidBody(body components.RigidBody3D) *Node3D
WithRigidBody attaches a 3D rigid body to the node.
func (*Node3D) WithStaticBody ¶ added in v0.1.7
WithStaticBody attaches a 3D static body marker to the node.
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
Scene is a simple wrapper around the ECS world. It provides convenience methods for entity management.
func NewScene ¶
func NewScene() *Scene
NewScene creates a new scene with an ECS world. If a default Window has previously been created via core.New(...), the scene will automatically start processing (input, registered systems, and entity callbacks) without the developer having to call StartProcessing manually.
func (*Scene) AddCharacterBody3D ¶ added in v0.1.7
func (s *Scene) AddCharacterBody3D(entity ecs.Entity, body components.CharacterBody3D)
AddCharacterBody3D attaches a CharacterBody3D to an entity.
func (*Scene) AddEntityCallbacks ¶ added in v0.1.7
func (s *Scene) AddEntityCallbacks(entity ecs.Entity, start func(*ecs.World, ecs.Entity), process func(*ecs.World, ecs.Entity, float32), physics func(*ecs.World, ecs.Entity, float32))
AddEntityCallbacks registers per-entity lifecycle callbacks. Any of the callback parameters may be nil if not needed.
func (*Scene) AddMaterial3D ¶ added in v0.1.7
func (s *Scene) AddMaterial3D(entity ecs.Entity, material components.Material3D)
AddMaterial3D sets or replaces the Material3D component on an entity.
func (*Scene) AddMesh3D ¶ added in v0.1.7
func (s *Scene) AddMesh3D(entity ecs.Entity, mesh components.Mesh3D)
AddMesh3D sets a Mesh3D component on an existing entity.
func (*Scene) AddPhysicsCallback ¶ added in v0.1.7
AddPhysicsCallback registers a physics callback for the given entity.
func (*Scene) AddProcessCallback ¶ added in v0.1.7
AddProcessCallback registers a per-frame process callback for the given entity.
func (*Scene) AddRigidBody3D ¶ added in v0.1.7
func (s *Scene) AddRigidBody3D(entity ecs.Entity, body components.RigidBody3D)
AddRigidBody3D attaches a RigidBody3D to an entity.
func (*Scene) AddStartCallback ¶ added in v0.1.7
AddStartCallback registers a start callback for the given entity.
func (*Scene) AddStaticBody3D ¶ added in v0.1.7
AddStaticBody3D marks an entity with StaticBody3D.
func (*Scene) AddTransform3D ¶ added in v0.1.7
func (s *Scene) AddTransform3D(entity ecs.Entity, t components.Transform3D)
AddTransform3D sets the Transform3D component on an existing entity.
func (*Scene) CreateBox3D ¶ added in v0.1.7
func (s *Scene) CreateBox3D(width, height, depth float32, material components.Material3D) ecs.Entity
CreateBox3D creates a rectangular box entity with a mesh and optional material.
func (*Scene) CreateCamera3D ¶ added in v0.1.7
func (s *Scene) CreateCamera3D(camera components.Camera3D) ecs.Entity
CreateCamera3D creates a camera entity in the scene and marks it as the active camera. The provided camera value will be stored as the Camera3D component; pass components.NewCamera3D() or a modified copy to configure.
func (*Scene) CreateCube3D ¶ added in v0.1.7
func (s *Scene) CreateCube3D(size float32, material components.Material3D) ecs.Entity
CreateCube3D creates a cube entity with a mesh and optional material.
func (*Scene) CreateEntity ¶
CreateEntity creates a new entity in the scene.
func (*Scene) CreateEntity3D ¶ added in v0.1.7
CreateEntity3D creates and tags a new entity as part of the 3D world.
func (*Scene) CreatePlane3D ¶ added in v0.1.7
func (s *Scene) CreatePlane3D(width, depth float32, material components.Material3D) ecs.Entity
CreatePlane3D creates a plane entity with a mesh and optional material. If material is the zero value, DefaultMaterial3D will be used.
func (*Scene) DestroyEntity ¶
DestroyEntity removes an entity from the scene.
func (*Scene) RegisterPhysicsSystem ¶ added in v0.1.7
RegisterPhysicsSystem registers a fixed-step physics system that will be called during the window physics step when StartProcessing is invoked.
func (*Scene) RegisterProcessSystem ¶ added in v0.1.7
RegisterProcessSystem registers a per-frame system that will be called during the window process step when StartProcessing is invoked.
func (*Scene) SetDefaultCamera ¶
SetDefaultCamera creates a default camera entity and returns it.
func (*Scene) StartProcessing ¶ added in v0.1.7
StartProcessing wires the registered systems into the provided window's process and physics callbacks so the engine updates systems automatically.
type Scene3D ¶ added in v0.1.7
type Scene3D struct {
// contains filtered or unexported fields
}
Scene3D owns reusable 3D scene-building helpers on top of the ECS world.
func NewScene3D ¶ added in v0.1.7
NewScene3D creates a reusable 3D scene controller.
func (*Scene3D) CameraEntity ¶ added in v0.1.7
CameraEntity returns the ECS entity used as the active camera.
func (*Scene3D) SetCamera ¶ added in v0.1.7
SetCamera selects the active camera entity for the scene.
func (*Scene3D) SpawnCamera ¶ added in v0.1.7
SpawnCamera returns a node preconfigured with a Camera3D component.
func (*Scene3D) SpawnCube ¶ added in v0.1.7
SpawnCube returns a node preconfigured with a cube mesh.
func (*Scene3D) SpawnPlane ¶ added in v0.1.7
SpawnPlane returns a node preconfigured with a plane mesh.
type ScreenType ¶ added in v0.1.7
type ScreenType string
ScreenType controls how the game view responds to window size changes.
const ( // ScreenTypeSame keeps a fixed logical game resolution with letterboxing. ScreenTypeSame ScreenType = "same" // ScreenTypeExpand keeps a fixed logical game resolution and fills the output without distortion. ScreenTypeExpand ScreenType = "expand" )
type Signal ¶
type Signal struct {
// contains filtered or unexported fields
}
Signal is a thread-safe event broadcaster inspired by Godot 4 signals. It implements the observer pattern with minimal overhead and optimized lookup. Listeners are functions with a variadic `...any` argument list.
func GetEntitySignal ¶
GetEntitySignal returns an entity-scoped signal.
func GetGlobalSignal ¶
GetGlobalSignal returns a global signal by name.
func GetScopedSignal ¶
func GetScopedSignal(scope SignalScope, owner, name string) *Signal
GetScopedSignal returns an existing signal for the given scope/owner/name, or nil.
func GetSystemSignal ¶
GetSystemSignal returns a previously registered signal, or nil if none.
func NewSignal ¶
func NewSignal() *Signal
NewSignal creates a new Signal with optional metadata name.
func RegisterEntitySignal ¶
RegisterEntitySignal ensures an entity-scoped signal exists.
func RegisterEntitySignalDef ¶
RegisterEntitySignalDef registers an entity signal with metadata.
func RegisterGlobalSignal ¶
RegisterGlobalSignal ensures a global signal exists.
func RegisterGlobalSignalDef ¶
RegisterGlobalSignalDef registers a global signal with metadata.
func RegisterScopedSignal ¶
func RegisterScopedSignal(scope SignalScope, owner, name string) *Signal
RegisterScopedSignal ensures a signal exists for the given scope/owner/name. Returns the Signal for optional further configuration or manual connection.
func RegisterScopedSignalDef ¶
func RegisterScopedSignalDef(scope SignalScope, owner string, def *SignalDef) *Signal
RegisterScopedSignalDef registers both a signal and its metadata definition. This enables introspection: developers can query what signals a system emits.
func RegisterSystemSignal ¶
RegisterSystemSignal ensures a signal exists for the given system and name and returns it.
func RegisterSystemSignalDef ¶
RegisterSystemSignalDef registers a signal with metadata documentation. Example: RegisterSystemSignalDef("TimerSystem", &SignalDef{Name: "timeout", Description: "Emitted when timer expires", ArgTypes: []string{"Entity", "uint64"}})
func (*Signal) Connect ¶
Connect registers a callback and returns an identifier you can use to disconnect.
func (*Signal) Disconnect ¶
Disconnect removes a previously registered listener by id.
func (*Signal) Emit ¶
Emit calls all listeners with the provided arguments (synchronous, immediate).
func (*Signal) ListenerCount ¶
ListenerCount returns how many listeners are connected to this signal. Useful for deciding whether to emit before building the args.
type SignalDef ¶
type SignalDef struct {
Name string // e.g., "timeout", "body_entered"
Description string // Human description of when this signal fires
ArgTypes []string // Type names of arguments, e.g., []string{"Entity", "uint64"}
}
SignalDef describes a signal's metadata: name, arg types, and description. This enables compile-time documentation of what signals a system emits.
func GetEntitySignalDef ¶
GetEntitySignalDef returns metadata for an entity signal.
func GetGlobalSignalDef ¶
GetGlobalSignalDef returns metadata for a global signal.
func GetScopedSignalDef ¶
func GetScopedSignalDef(scope SignalScope, owner, name string) *SignalDef
GetScopedSignalDef returns the metadata for a signal if it was registered via RegisterScopedSignalDef.
func GetSystemSignalDef ¶
GetSystemSignalDef returns metadata for a system signal if registered.
type SignalScope ¶
type SignalScope string
const ( SignalScopeGlobal SignalScope = "global" SignalScopeSystem SignalScope = "system" SignalScopeEntity SignalScope = "entity" )
type Window ¶
type Window struct {
Title string
Width int32
Height int32
Flags []sdl.WindowFlags
PhysicsStep float32 // seconds per physics tick (default 1/60)
// contains filtered or unexported fields
}
func DefaultWindow ¶ added in v0.1.7
func DefaultWindow() *Window
DefaultWindow returns the window created by the last call to New(), if any.
func (*Window) OnPhysicsProcess ¶
OnPhysicsProcess registers a fixed-step physics callback receiving fixed dt.
func (*Window) OnReady ¶
func (w *Window) OnReady(cb func())
OnReady registers a callback to run once before the main loop starts.
func (*Window) RunWithUpdate ¶
func (w *Window) RunWithUpdate(update func())
func (*Window) ScreenType ¶ added in v0.1.7
func (w *Window) ScreenType() ScreenType
ScreenType returns the currently configured screen type.
func (*Window) SetClearColor ¶
SetClearColor sets the clear color used at the start of each rendered frame.
func (*Window) SetClearColorHex ¶
SetClearColorHex sets clear color from hex: #RGB, #RGBA, #RRGGBB, #RRGGBBAA. The leading # is optional.
func (*Window) SetPhysicsStep ¶
SetPhysicsStep sets the fixed-step physics delta in seconds.
func (*Window) SetScreenType ¶ added in v0.1.7
func (w *Window) SetScreenType(screenType ScreenType, logicalW, logicalH int32) error
SetScreenType configures how rendering adapts to window size changes. For ScreenTypeSame, logicalW/logicalH must be > 0 and are used as the fixed game resolution.
func (*Window) ViewportSize ¶ added in v0.1.7
ViewportSize returns the active gameplay viewport dimensions.