In my breakout implementation there are two main behaviors that describe the game's main state:
paddlePosition :: Behavior t Point
ballPosition :: Behavior t Point
Both are implemented in terms of tickEvent :: Event t ()
which discretely
updates them.
The gameOverEvent :: Event t ()
filters all tick events where the ball
position is below the screen.
I would like to replace paddlePosition
by a new behavior as soon as there
is a gameOverEvent
, leaving the paddle in place, in pseudo code:
newPaddlePosition = \t -> case gameOverEvent of
[] -> paddlePosition t
((t',()) : _) -> paddlePosition t'
The first question is: How do I express newPaddlePosition
using
reactive-banana?
The second is question is a bit more vague: What is a good way to organize the
whole program depending on if the game is over or not? There are other
considerations like: How to handle ballPosition
, how to draw the game, and so
on.