This started as a university project which I extended later.
The small engine generates terrains of different shape, size and surface texture, based on any bitmap files provided for it. The concept of the game is not really fancy. You try to find the best path to the target from the start point (both random and on 2 opposite edges of the terrain.) and try to beat your high score or compare to the best suggestion by the computer. Best path is defined as the one with minimum climbing in total.
Some characteristics of it:
- Programmed in C++. Though the multi-threaded functionality is basically pure C.
- Somehow Multi-platform. Same code compiles and runs on Windows and Linux (and theoretically on Mac but I haven’t tried it since early versions). This is achieved in part by (but not limited to) the use of the STL library.
- OpenGL-based and uses separate compiled shaders for various objects.
- Most things are defined in headers. This is not a full engine with editors and everything. But it is easily modifiable with little or no need of adjustment on the actual code.
- Light source and camera are movable (one might call it dynamic but I’d rather not use the term since the constraints I have put in place for their move.)
- For lighting, some of the normals are calculated automatically like in case of the generated terrain itself. But some objects use normal maps (textures).
- A* path-finding (built specifically for the purpose, not from a prefab library) to compare the user’s chosen path to the one used by the computer.
- Fairly satisfactory performance. The screenshots you see here have around 270,000 visible polygons in viewport and fps never drops below 30 on an old computer with a 1.7GHz CPU, although it uses a custom mesh class containing various std::vector structures to improve code readability.
- It uses a simple level of multi-threading. While the user is playing, the computer spends a second or 2 to calculate the best path behind the scene without a hiccup on the user experience.
[This is change of one line in the header. The terrain has quarter of the previous one’s polygons but everything for the looks and gameplay is adjusted by the program.]
[The green area is the places checked by the A* algorithm. The Yellow area would have been the next candidates for the path if the optimal path (blue) was not already found.]