Jump to content

  • Log In with Google      Sign In   
  • Create Account





Isometric Map in SFML

Posted by JTippetts, 25 June 2011 · 26,514 views

isometric rpg 2D SFML
In my ever-so-humble opinion, "traditional" 2D isometric games (ie, games implemented using only 2D techniques to fake an isometric viewpoint) are as dead as last week's meatloaf. Traditional techniques present a number of problems that are solved by hacks and kludges, but which are solved much more elegantly via a 3D approach. Nevertheless, when someone is just starting out with game programming, 3D can be intimidating. Also, maybe you're looking to go retro, and while 3D can benefit even a retro style, still it might be more feasible to implement a traditional 2D system. I personally rarely use traditional 2D in my own projects anymore, but I found this on my hard-drive and updated it. The system is based on the original 2D system upon which I built my older game, Golem, albeit modified to work with 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:
Attached Image

Attached Image


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:

Attached File  isometric.zip (2.67MB)
downloads: 1872


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.





Attached Thumbnails

  • Attached Image
  • Attached Image
  • Attached Image
  • Attached Image





Hardcore. Cheers. Interesting read. I totally agree that it would be preferrable these days to just do this in 3D, but I've found most iso-tutorials to be horribly overcomplex so this is a great addition to teh interwebz anyway.
Originally published 6/23 - date bumped for featuring purposes
Nice work!
SFML is good stuff! but yeah, traditional 2D Iso has gone the way of the dodo for all but niche, edutainment and very casual type applications.
This is really great. I dont use SFML, I use Java and Slick2d/LWJGL.. but since thats all build on openGL,..I should be able to apply some of this stuff directly. I really want to try out a simple lighting system like youve done. WE NEED MORE ARTICLES LIKE THIS!
Im not sure what you(and comments) mean by going 3D preferably..Its not a question of programming choice, but art style choice you know..
Unless you mean something like Disgaea, with 2D sprites on top of a 3D environment, but if you want 2D environment, 2D tile'ing' on top of 3D..Is it even possible?(probaly even more complicated)
A good exemple of 2D iso game is the mmorpg Dofus, the art is just awsome, and its not an old school game.

That comes of the top of my head, cause Im a fan of iso games, and I plan to make my iso cubic engine someday.

Good article, thanks for sharing.
PARTNERS