Safe Haskell | None |
---|---|
Language | Haskell2010 |
Helm.Time
Contents
Description
Contains functions for composing units of time and subscriptions to events from the game clock.
- type Time = Double
- millisecond :: Time
- second :: Time
- minute :: Time
- hour :: Time
- inMilliseconds :: Time -> Double
- inSeconds :: Time -> Double
- inMinutes :: Time -> Double
- inHours :: Time -> Double
- now :: Engine e => (Time -> a) -> Cmd e a
- every :: Engine e => Time -> (Time -> a) -> Sub e a
- fps :: Engine e => Int -> (Time -> a) -> Sub e a
Types
Represents an amount of time in an arbitary unit. This type can then be composed with the relevant utility functions.
Units
A time value representing one millisecond.
inMilliseconds :: Time -> Double Source
Converts a time value to a fractional value, in milliseconds.
Commands
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
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.
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.