This time I was interested in JavaFX 2 and again I was developing a little game as an example. Again I tried a “snake” like game as you probably know from old mobile phones. As the player you are controling a Snake that eats food that is laying around. Everytime you eat something to gather points and grow a little bit. The goal is to gather as many food as you can without byting yourself in the tail. In my version of the game there are no walls: When you move outside of the field on the left side you are immediatelly returning on the right side.
The development started in october 2012 with some experiments with JavaFX, FXML and dependency injection. The first version of the game was based on maven and javaFX version 2. In november 2012 the first version of the game was ready. It was based on maven and JavaFX in version 2. The dependency injection was implemented by hand without a DI framework.
After a long pause with no coding in may 2013 I returned to the project and started with a big refactoring. The code wasn’t realy nice and the coupling between the components of the game was relatively tight. The idea of the refactoring was to encapsulate the state of the UI in a ViewModel. Another change was the usage of JSON for persisting highscores instead of CSV. This way I was able to remove a lot of code for CSV parsing.
In november 2013 again I made some changes to the game after another pause. The biggest change is the use of Gradle as build system instead of maven. I also done a big refactoring of the dependency injection system and simplified the code of the program. Another big simplification was the usage of Java 8 instead of Java 7.
The code of the game can be found on github: https://github.com/lestard/snakefx