[Haskell-beginners] firering event in netwire
es at ertes.de
Mon Oct 1 14:22:38 CEST 2012
Nathan Hüsken <nathan.huesken at posteo.de> wrote:
> >> But this does not do the accumulation every frame, but whenever an
> >> event happens.
> > That wire by itself does the accumulation at every frame, so you
> > probably have an inhibiting wire earlier in the chain.
> Let me restate my problem. My wire is this:
> pos = accum (+) 0.0 . speed
> and all I do is putStrLn the output at every frame.
As a side note, see testWire and testWireM in Control.Wire.Session. =)
> If withing one frame where speed has the value (1) several events are
> sent over the wire (for example several keyup and keydown events for
> an unrelated key), then pos gets incremented for one for each of this
> events. So I have to prevent the accumulation if the event is not
That's because you're using constant time deltas. Even if your time
frame has a constant rate you should still make use of your time deltas.
In particular notice that Netwire can deal with time deltas of 0. Then
instead of accum you would use integral_.
Not to be or to be and (not to be or to be and (not to be or to be and
(not to be or to be and ... that is the list monad.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: not available
More information about the Beginners