Written by Simon Bächler and Marco Wettstein
In this tutorial we are going to create a game in elm. The game is based on the great arcade game Hexagon. That game was the prototype for the successful mobile game Super Hexagon.
You can check out the final result here
The tutorial requires some knowledge of the concepts of functional programming. You should also have read the section about the Elm architecture. The game is building upon this and uses the Model-Update-View pattern.
This is an intermediate-level tutorial. The final program is about 434 lines of code.
It is based on Elm 0.17, which uses a different approach than 0.16. In fact we were almost done with the tutorial when 0.17 came out and dropped Signals in favor of Commands. So we decided to rewrite everything to be 0.17 compliant and use the new architecture.
The ecosystem is not complete yet and the move to a new API broke a few useful tools like the Elm debugger.
While Elm is currently only compiling to Javascript this might change in the future. That’s why it is not possible anymore to have external libraries that use native bindings such as the Web audio API. Until Elm core supports this we are going to have to work around this limitation (as you will see in chapter Music).
The tutorial is is split up in seven chapters, each with a special focus. By the end of each chapter you will have a running program.
You can check out the full source code of each chapter: here. Each chapter has its own branch.
The authors wish to thank Terry Cavanagh for letting us use his game for this tutorial.