Thinking about games in general leads you to design a rather complex system in which you'd have several independent entities interacting on the playing board. This seems to be a perfect case for core.async
, especially considering how plain JavaScript code could have become bloated had you gone the classical way: laying out a solution inside a single huge loop. In fact, core.async
and ClojureScript
will enable us to design a very elegant and human-readable solution, one considering every element of the UI as an independent co-routine, executing concurrently and communicating through channels.
Imagine that you want to design a very simple game in which balls are falling from the sky and you must catch as many of them as you can with your bucket. But beware: if a single ball hits the floor, the game is over. Each time you are able to catch a ball, your score increases.
Out of these requirements, we can detect several processes that we'd have to build in order to give birth...