My network looks like this:
ePhysics :: Event t ()
bPlayerForce :: Behavior t (Double,Double)
bPlayerPosition :: Behavior t (Double, Double)
ePhysics is fired repeatedly from a timer.
I'm having issues with defining bPlayerPosition. What I intend is that it will start at (0,0), and whenever ePhysics is fired, bPlayerPosition will be recalculated using bPlayerForce as a parameter.
The problem is that in-order to specify an initial value I need to use accumB/stepper but they only work with events, and I can't get the force value from bPlayerForce since only behaviors can get the value of other behaviors (with <*>).
The alternative would be just using <*> but with that I have no initial value, so it becomes a meaningless infinite recursion:
let bPlayerPosition = pure calcPosition <*> bPlayerForce <*> bPlayerPosition
I have 3 questions:
<*>? like, when reactimateing or mapping an event? the issue of not being able to has been screwing with me constantly since the very start.apply combinator, also called <@>, and its variant <@ provide a way to sample a Behavior whenever an event happens.ePhysics event.Something along the lines of
let bPlayerPosition = stepper (0,0) $
(calcPosition <*> bPlayerForce <*> bPlayerPosition) <@ ePhysics
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With