A year ago, I made 2048 in the console. I did it in less than 500 lines of code and I had made it with the game board drawing separate from the rest of the game with the intention of swapping out the display to a graphical one. A year later and that paid off because it was fairly simple to just drop in the game logic to my SharpDX template.
I did unfortunately separate out the generating of new pieces into its own class. This caused the code flow in an awkward way when the game resets, but it works. The code I wrote is about 2500 lines. Most of that is in the menu system that I started in my Matrix Falling Code project. I extended the functionality of the system to include text input and toggle controls.
I also created a way for menus to hand off to other menus. It was good practice in polymorphism. This was required to have sub menus and do things like get the played to enter their name to be saved in the high scores list. The project was a good example in the difference between a project that just does the bare minimum and one that is fully featured. I streamed about 16 hours of me working this on twitch and I probably spent another 4 off stream working on the project. I’m pleased with the result for 20 hours of effort.
I’ve published the code on my Github.
Here are a few of the menus in the game.