[Haskell-beginners] firering event in netwire
nathan.huesken at posteo.de
Mon Oct 1 13:31:04 CEST 2012
On 09/30/2012 05:39 AM, Ertugrul Söylemez wrote:
> However, I rather recommend against passing multiple SDL events at once.
> Wires can handle individual events much better and, when properly
> designed, also faster.
Ok, so I update my wire on every event I receive. That way I only have
one event for every wire update.
Now I want my state updates frame based, not time based. I am trying to
update the state based on the NoEvent event (the main look takes care
that this happens in an constant interval).
I have an Event Wire
isKeyPressed code :: EventP SDL.Event"
which produces when the key is pressed and inhibits when it is not pressed.
speed = (((pure (-1.0)) . isKeyPressed leftKeyCode) <|> pure 0.0)
(((pure 1.0) . isKeyPressed rightKeyCode) <|> pure 0.0)
So speed is -1 if the left key is pressed, +1 if the right key is
pressed and 0 if none or both are pressed.
Now I want to integrate this speed (frame based):
pos = accum (+) . speed
But this does not do the accumulation every frame, but whenever an event
So I would need a "require (==NoEvent)" somewhere. But I do not see
where I could put it to archive the desired behavior.
I am not sure if I am using netwire correctly.
Thanks & Regards,
More information about the Beginners