[Haskell-cafe] Improving event management in elerea

jean legrand kkwweett at yahoo.fr
Fri Aug 14 05:37:10 EDT 2009


> so you'd jump a huge amount in every frame. What I had in

can you explain, please ? I can't feel it when I play.

> something like this:
> 
> ifte :: Signal Bool -> Signal a -> Signal a ->
> Signal a
> ifte sc st sf = (\c t f -> if c then t else f) <$>
> sc <*> st <*> sf 
> 
> And then:
> 
> playerX <- integral playerX0
>              ( ifte
> (lpress &&@ (playerX >@ pure (-fieldW))) (-1) 0
>              + ifte
> (rpress &&@ (playerX <@ pure (fieldW-playerW)))
> (1)
>              0
>              )
> 

looks better indeed since there isn't a double signal anymore

> This won't be perfect, since the paddle can get a bit
> beyond the edge of
> the field. This can be prevented by using some kind of
> clamped integral,

or using some rounding as I did in my first implementation ?

> 
> Also, note that mixing bind and return is redundant, since
> "f =<< return
> b" is equivalent to "f b".
> 

yes, of course ! one of The laws, thanks !



      


More information about the Haskell-Cafe mailing list