This demo program represents the implementation of the "15 puzzle" in the C++ programming language in a function-oriented style with a division into functional layers.
The program interface is made minimalistic, but understandable:
- Using separate template classes (modules) to separate the areas of responsibility of modules.
- Event-driven approach through the use of CallBack-functions.
- Using pure WINAPI (no ALT and MFC) when working with graphics.
- Using exclusively WINGDI (instead of GDI+) for rendering any primitives, as well as text.
- Exclusively custom rendering (the buttons provided by the system were not used).
- Implementation of saving history in such a way that data on 4 moves are placed in one byte.
- Unicode functions are used to display text, which simplifies localization.
- Two win check algorithms: classic and snake. The first is active by default, and the second can be activated by uncommenting the lines of code marked SnakeAlg. This algorithm determines the payoff if it is possible to get from cell "1" to "15" by passing through neighboring cells (for example, cell "2" is searched around cell "1", then cell "3" is searched around cell "2", and so on). The SnakeAlg algorithm is disabled by default due to the fact that it violates the rules of the classic game.
- A good structural template for the implementation of any simple "passive" game (i.e. a game where all events are generated exclusively by the user, there are no in-game events).