Showing posts with label Tiles. Show all posts
Showing posts with label Tiles. Show all posts

Sunday, February 27, 2011

Tile Based Games

If you looked at a collection of 2D games, how many of them do you think would use a tile based system for drawing their environments? I'm going to hazard a random guess and say, "lots". So, if this is pretty standard stuff, why re-invent the wheel? Well recently, one of my awesome students pointed out a pretty fantastic tool and code library to me that does tiled maps -quite- well. I like enough that I'd probably use it in any of my own 2D projects, and would recommend it to anyone else.


The Tiled map editor in action, incredibly simple, incredibly powerful.

The map editor, Tiled, does everything it needs to, and nothing really more. It works with multiple layers of tiles, as well as simple object layers for placing objects that don't quite qualify as tiles. You can attach your own custom properties to any tile, layer or map in your project, so that you don't actually need any other editor to design your project in.

The designer allows you to fill areas with a paint bucket, as well as select multiple tiles to place simultaneously, a pair of features that greatly increase work speed for designing your maps. Hotkeys are provided for all commands, so with a little bit of practice, you should be able to iterate through map designs in minutes!

Also, did I mention that their undo history is killer? It really is, give it a try =D For documentation on the application, check out their wiki.

Integration with XNA

The editor by itself is fantastic, but half the problem is getting the stuff from the editor to the screen. Fortunately for everyone involved, a fellow by the name of Gareth Williams wrote a fairly friendly framework for loading/displaying/working with files generated from Tiled in XNA 4.0.

While I have not spent extensive amounts of time with this framework yet, a cursory glance reveals some pretty cool things, and some fairly solid code. Even better is that large parts of his code are based on widely popular and easily accessible tutorials. He's also quite amiable to the idea of other people using this code too, which is always a plus. Here's a link to the relevant posts from his blog. I strongly recommend at least checking it out, it could save you a world of time!

Links

Tiled editor
Tiled editor Wiki page

Gareth Williams Tile Engine
Game State Management Sample (used in the Tile Engine)
Nick Gravelyn's commentary on TiledLib, and TiledLib itself (also used in the Tile Engine)