I wrote a little game in scala; House of Mirrors. It is a logic game heavily inspired by Chromatron.
It was just a for-fun project and I also wanted to familiarize myself with scala with a real-world application.
My notes:
- I first wrote the core of the game, with no interface at all. It was probably about 100 lines of Scala code. I found I could easily design and code on the go.
- I built up all objects using a hierarchy of case classes and stuck to immutable data types.
- Adding a GUI layer on top of the core was easy with the SQUIB library. I think the total code was about 400 lines of code.
- However, when dealing with colored light beams I had to get my hands dirty with Swing, since I wanted to define my own Composite class. I found some missing functionality in AWT and had to use Double buffering while compositing. This is what to took most of my time, though it’s just 17 lines of code
- The next part was saving and loading game files in XML format. Needless to say, this was a breeze to write in Scala. Total code was about 500 lines of code
- After a lot of game features and minor GUI enhancements the code now stands at 1k loc
The biggest hurdle I faced when dealing with Scala was a lack of documentation for the standard APIs. The others being : instability of the compiler itself, changing APIs and some inconsistencies in the language. An example of the latter; “case North” is treated differently from “case north”! why? because capitalisation of identifiers is treated specially! Bad design choice I think; it’s too quirky.
Most of these problems should go away with time & love but some like the above quirkiness are potential hair-pullers.