Isometric Map in SFML
isometric rpg 2D SFML
Presented here is an example of how you might go about implementing a traditional 2D isometric map using SFML. I chuckle as I write this, since SFML is just a 2D front-end sitting on top of OpenGL which is, of course, a 3D API. Nevertheless, SFML is implemented to be a 2D library, and so it might be nice to have an isometric map system that works with SFML without having to delve into OpenGL.
At the end of this article, we will have a working 2D isometric map of arbitrary size, with a basic tile-based lighting scheme, suitable for some sort of graphical roguelike or other 2D RPG-type game. I will provide all of the code, and a working demo. I will discuss the structure of the map, the organization of the lighting scheme, how it all fits together with SFML. I will also touch on a few of the issues and caveats that crop up when using an old-school 2D system, and why using 3D makes things so much easier.
To see what we are shooting for, here are a couple screenshots of the final product:
Now, I explain in the remainder of this post how the system works. If you don't care, already know enough about isometric maps, etc... and just want to get to the code, here is the archive:
Included is all the source, including source to bind SFML to Lua, the isometric map code presented here, and a small sample Lua application demonstrating the system. Tinker to your heart's content. Be warned, though, that this has been sitting on my harddrive mostly untouched for a couple years now, and there might be bugs a-lurking. Since it's not code I commonly use, it hasn't been very thoroughly tested.