Documentation
¶
Overview ¶
Package piroutine provides functionality similar to coroutines found in other languages (e.g., Lua). It allows you to create Routines, which are programs composed of a sequence of steps, typically executed over many game frames.
This package helps you write more readable code, but at the cost of more difficult debugging and higher resource usage. Recommended for cases where your logic can be expressed as a sequence of steps, such as creating animations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Routine ¶
type Routine struct {
// contains filtered or unexported fields
}
Routine is a program composed of a sequence of steps, typically executed over multiple game frames.
func (*Routine) Resume ¶
Resume resumes the execution of the Routine.
It returns true if the Routine has not yet finished and can be continued by calling Resume again.
func (*Routine) ScheduleOn ¶
ScheduleOn schedules the Routine to resume on the given event.
Each publication of the event will call Resume.
Returns a handler that can be unregistered from piloop.Target to stop further resuming.
func (*Routine) SetTracing ¶
SetTracing enables or disables logging of each step execution.
Very useful for debugging a Routine.
type Step ¶
type Step func() bool
Step is a single step in a Routine.
It returns true when the step has finished and the next step in the Routine can be executed
func Call ¶
func Call(f func()) Step
Call creates a Routine step that executes the given function and immediately advances to the next step