helm-1.0.0: A functionally reactive game engine.

Safe HaskellNone
LanguageHaskell2010

Helm.Time

Contents

Description

Contains functions for composing units of time and subscriptions to events from the game clock.

Synopsis

Types

type Time = Double Source

Represents an amount of time in an arbitary unit. This type can then be composed with the relevant utility functions.

Units

millisecond :: Time Source

A time value representing one millisecond.

second :: Time Source

A time value representing one second.

minute :: Time Source

A time value representing one minute.

hour :: Time Source

A time value representing one hour.

inMilliseconds :: Time -> Double Source

Converts a time value to a fractional value, in milliseconds.

inSeconds :: Time -> Double Source

Converts a time value to a fractional value, in seconds.

inMinutes :: Time -> Double Source

Converts a time value to a fractional value, in minutes.

inHours :: Time -> Double Source

Converts a time value to a fractional value, in hours.

Commands

now Source

Arguments

:: Engine e 
=> (Time -> a)

The function to map the running time to an action.

-> Cmd e a

The mapped command.

Map the running time of the engine to a game action. Note that this is not the current clock time but rather the engine time, i.e. when the engine first starts running, the applied value will be zero.

Subscriptions

every Source

Arguments

:: Engine e 
=> Time

The interval of time to produce events at.

-> (Time -> a)

The function to map the running time to an action.

-> Sub e a

The mapped subscription.

Subscribe to the running time of the engine and map to a game action, producing events at a provided interval.

fps Source

Arguments

:: Engine e 
=> Int

The frames per second.

-> (Time -> a)

The function to map the time delta to an action.

-> Sub e a

The mapped subscription.

Subscribe to events that emit at a provided frames per second and map to a game action, producing events at a provided interval. The time value applied is the delta between the current and last event emission time.