I've now resolved that issue by creating a base solution with a ready-to-go tile engine that is suitable for side scrollers, top down and RPG-style maps. I've decided to release it so that anyone else in my position should be able to pick up this base solution and get cracking on tile-based games.
The solution imports maps created with Tiled.
Here's a video of the engine in motion:
And a handy list of all the features of the solution:
- Suitable for side-on and top-down games
- Good for platformers, RPGs, shooters, racers, adventures - anything that needs tiles!
- Works in landscape or portrait with one line change.
- Built on the Windows Phone 7 XNA Gamestate Management engine sample.
- Uses Nick Gravelyn's content pipeline extension for the "Tiled" editor.
- Simple but flexible camera class that clamps to the map boundaries.
- Draw the whole map at once, or one layer at a time for flexibility.
- Parallax scrolling simply by adding a couple of properties to a layer in Tiled.
- An overload to draw a layer as "shadows" by drawing offset+black+semi-transparent.
- Per-pixel colour-based collision detection on specified layers/tilesets.
I've added a whole bunch of comments to hopefully help some beginners along the way. Please note that this is just a base engine for a game, and won't help you magically write your actual game mechanics!
This is the first time I've released some code with the intention of helping other developers, so please leave comments below. I'll address any questions in future posts. If anyone with a real device reads this, please consider giving it a run on a real phone - I'd love to know how it performs (if it runs at all!). Take some video as well!
A few screenshots next, download link is at the bottom of the post!
Tiles used in the solution are released freely at Lost Garden.
Please note that the solution is built on XNA 4.0 and will not compile using older versions of the XNA SDK.
Download the solution: http://www.team-mango.com/stuff/phone7tilebase.zip