The question is somewhat vague and not easy to answer, but I will try my best.
Firstly, looking at your code, it seemed strange to you that you "passed the third-party" logic of the game process to the monolithic type GameState and the updateGS function. Now this is not bad, but there is simply no benefit in using FRP in this style. You can completely remove the makeNetworkDescription function and instead register an even thandler with addCommandEvent .
The advantage of FRP is that you can model the state of a game as a network of behavior and events. If the state is sufficiently modular, this will greatly simplify the code.
Secondly, regarding your question about hyperspace modeling.
Here is one way to do this:
-- indicates whether hyperspace travel is currently happening bTravelling :: Behavior t Bool -- increment travel distance, but only when travelling bTravelDistance :: Behavior t Distance bTravelDistance = accumB 0 $ (+1) <$> whenE bTravelling eTick -- calculate player location from travel distance bPlayerLocation :: Behavior t Location bPlayerLocation = (\distance -> if distance > total then Left Planet else Right HyperSpace) <$> bTravelDistance
You probably want to repeat this process several times in the game. Unfortunately, reactive banana does not currently suggest βdoing it first and then doing itβ as an abstraction. There is dynamic event switching, but this can be a bit cumbersome.
Heinrich apfelmus
source share