helm-0.7.0: A functionally reactive game engine.

Safe HaskellNone

FRP.Helm.Time

Contents

Description

Contains functions for composing units of time and signals that sample from the game clock.

Synopsis

Units

type Time = DoubleSource

A type describing an amount of time in an arbitary unit. Use the time composing/converting functions to manipulate time values.

millisecond :: TimeSource

A time value representing one millisecond.

second :: TimeSource

A time value representing one second.

minute :: TimeSource

A time value representing one minute.

hour :: TimeSource

A time value representing one hour.

inMilliseconds :: Time -> DoubleSource

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

inSeconds :: Time -> DoubleSource

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

inMinutes :: Time -> DoubleSource

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

inHours :: Time -> DoubleSource

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

Tickers

fps :: Double -> Signal TimeSource

Takes desired number of frames per second (fps). The resulting signal gives a sequence of time deltas as quickly as possible until it reaches the desired FPS. A time delta is the time between the last frame and the current frame.

fpsWhen :: Double -> Signal Bool -> Signal TimeSource

Same as the fps function, but you can turn it on and off. Allows you to do brief animations based on user input without major inefficiencies. The first time delta after a pause is always zero, no matter how long the pause was. This way summing the deltas will actually give the amount of time that the output signal has been running.

every :: Time -> Signal TimeSource

Takes a time interval t. The resulting signal is the current time, updated every t.

Timing

timestamp :: Signal a -> Signal (Time, a)Source

Add a timestamp to any signal. Timestamps increase monotonically. When you create (timestamp Mouse.x), an initial timestamp is produced. The timestamp updates whenever Mouse.x updates.

Unlike in Elm the timestamps are not tied to the underlying signals so the timestamps for Mouse.x and Mouse.y will be slightly different.

delay :: Time -> Signal a -> Signal aSource

Delay a signal by a certain amount of time. So (delay second Mouse.clicks) will update one second later than any mouse click.

since :: Time -> Signal a -> Signal BoolSource

Takes a time t and any signal. The resulting boolean signal is true for time t after every event on the input signal. So (second since Mouse.clicks) would result in a signal that is true for one second after each mouse click and false otherwise.