Documentation ¶
Index ¶
- func MakeClock(fps FPS) (start func() (ticks <-chan Tick, stop func()))
- func WithDurationMetric(m *DurationMetric, f func())
- func WithDurationMetricResult[T any](m *DurationMetric, f func() T) T
- type App
- type DurationMetric
- type Engine
- type EngineMetrics
- type FPS
- type ReadBuffer
- type RenderState
- type Sprite
- type Tick
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDurationMetric ¶
func WithDurationMetric(m *DurationMetric, f func())
func WithDurationMetricResult ¶
func WithDurationMetricResult[T any](m *DurationMetric, f func() T) T
Types ¶
type App ¶
type App[GameState any] struct { FPS FPS Size image.Point InitialGameState GameState Update func(Tick, GameState) (GameState, RenderState) DebugEnabled bool }
type DurationMetric ¶
func (DurationMetric) AverageDuration ¶
func (m DurationMetric) AverageDuration() time.Duration
func (DurationMetric) AverageFPS ¶
func (m DurationMetric) AverageFPS() float64
func (*DurationMetric) Load ¶
func (m *DurationMetric) Load() DurationMetric
func (*DurationMetric) PutEvent ¶
func (m *DurationMetric) PutEvent(d time.Duration)
func (DurationMetric) String ¶
func (m DurationMetric) String() string
type Engine ¶
type Engine[GameState, RenderState any] struct { StartClock func() (ticks <-chan Tick, stop func()) Update func(Tick, GameState) (GameState, RenderState) Render func(RenderState, *image.NRGBA) StartDraw func(ReadBuffer) error Size image.Point Metrics EngineMetrics }
type EngineMetrics ¶
type EngineMetrics struct {
Start, Stop time.Time
LoopCount uint64
Update, Render DurationMetric
}
func MakeEngineMetrics ¶
func MakeEngineMetrics(now time.Time) EngineMetrics
func (*EngineMetrics) Load ¶
func (m *EngineMetrics) Load() EngineMetrics
func (EngineMetrics) Loop ¶
func (m EngineMetrics) Loop() DurationMetric
func (EngineMetrics) LoopAt ¶
func (m EngineMetrics) LoopAt(now time.Time) DurationMetric
type ReadBuffer ¶
type RenderState ¶
RenderState is whatever we send to the render function to draw on the image buffer.
Click to show internal directories.
Click to hide internal directories.