Re: [Haskell-cafe] Improving event management in elerea

can you explain, please ? I can't feel it when I play. Well, the paddle moves very fast that way, and its speed depends on the refresh rate. While the refresh rate is set in this program, it's not a good idea to depend on it in any way. Transfer functions provide access to the frame time, so you can adjust the speed to be independent of it.
or using some rounding as I did in my first implementation ? It's good if that works. However, I wouldn't depend on that either, since you might have to struggle with edge cases, and you also rely on the sizes being related to each other in various ways instead of choosing them freely. In my opinion, the best solution in this case would be a clamped integral, which would also make it unnecessary to check for the edge of the field in the condition (note that I make use of the Num instances of signals to take care of the lifting):
integralClamped v0 vmin vmax s = transfer v0 accum s where accum dt v v0 = max vmin $ min vmax $ v0+v*realToFrac dt playerX <- integralClamped playerX0 (-fieldW) (fieldW-playerW) (ifte lpress (-1) 0 + ifte rpress 1 0)
From these, integralClamped and ifte might also be good candidates for inclusion in the library.
Gergely -- http://www.fastmail.fm - Choose from over 50 domains or use your own

to the frame time, so you can adjust the speed to be independent of it.
ok, thanks
integralClamped v0 vmin vmax s = transfer v0 accum s where accum dt v v0 = max vmin $ min vmax $ v0+v*realToFrac dt
playerX <- integralClamped playerX0 (-fieldW) (fieldW-playerW) (ifte lpress (-1) 0 + ifte rpress 1 0)
I haven't quite understood yet so I'll see later but I already have another question : what if the functions are some signal functions . For instance, instead of being (subtract 1) :: a -> a, it is a signal func :: Signal (a ->a) ? Is there also a simple way to compose func with an (x :: Signal a) in order to produce a new signal ? I naively tried y=func <*> x but the influence of func doesn't seem to exceed a frame.
participants (2)
-
jean legrand
-
Patai Gergely