3 ms·
The way I did this was to design a more-or-less monadic container `Result<A>` for all my game logic functions. It batches a sequence of animation steps with a r
by sjrd 2y ago
The way I did this was to design a more-or-less monadic container `Result<A>` for all my game logic functions. It batches a sequence of animation steps with a result. It can also model error conditions (like not having enough resources for example). I can then instantiate it any concrete result type, such as a full game state or just the result of individual computations. It was very nice to concisely write complicated game logic with animations while retaining the happy path.
https://github.com/sjrd/barrage/blob/main/src/main/scala/be/doeraene/barrage/model/Result.scala https://github.com/sjrd/barrage/blob/main/src/main/scala/be/...
- LudwigNagasena 2y agoInteresting. Unfortunately, your repo seems to be private.
- sjrd 2y agoOh shoot, yes. I have imitation copies of the original game graphics in there, and so I can't make it public without violating copyright of their assets. :-( Here is a public gist with the `Result` data structure, as well a good portion of the file handling all the game mechanics, which should show it gets used. https://gist.github.com/sjrd/34fe234d1b6232cf42ffda5d23292d35 https://gist.github.com/sjrd/34fe234d1b6232cf42ffda5d23292d3...