Effective ways of using Tiled and the TiledMap class for a 2D platformer

Hi all,

I am just getting rolling on developing a 2D platformer in Monogame. I’m very early in on this project and am working on setting up the basics of the game. I have some limited experience with XNA and am fairly comfortable with programming (although some of the pieces of game development are still new to me). I am using the latest distribution of Monogame.extended on Nugent and have decided to use Tiled to design my levels. I chose to give Monogame.extended because it appears to have tmx parsing already implemented as well as a camera implementation (which were two things that I needed to implement anyways).

I would like some advice on the best way to develop using Tiled and the TiledMaps in Monogame.extended. In particular, what aspect of the TiledMap class lends itself best to making a 2D platformer (the sort of implementation explained in section #2 of http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/). I realize the tmx support in Monogame.extended is fairly new (hence why there aren’t a lot of examples). Can I use the Tiled Regions to represent platforms (platforms that my player will stand on)? I think that using an Object layer would make most sense, but the version of Monogame.extended currently distributed doesn’t seem to support that. Ideally I would make my collision detection checks by calculating which tiles my character is currently in and which tiles my character is attempting to move to and querying the TiledMap to see if that spot is open or not.

Any other tips for using these tools effectively would be much appreciated. Thanks!

Hi @gkericks

Thanks for trying the library. We’re working hard to make it as useful as possible.

We’ve made a lot of improvements to the Tiled code in the develop branch. I’m thinking we are just about ready to do another NuGet release once I get a few things in order. Until then, you’re welcome to try building from source. It’s actually not that hard.

So when you say “effective ways of using Tiled” for a platformer it appears you’re talking specifically about how to implement collision detection.

You’re right. This area of the library is still in development. However, there are a number of resources that could help you get a head start on it.

  1. We’ve got super basic collision detection already in the library. You can see a demo of it in action with Tiled in the sprite sheet animations demo. However, keep in mind this is an experimental bit of code and is likely to change significantly in future versions. Of course if it’s good enough to get you started you could always just copy and paste the bits you need into your project.

  2. @LithiumToast is working on something much better to replace this. He’s always active on our gitter chat. I’m sure he’d be happy to talk to you about it.

  3. In my travels I’ve ran into a couple of open source projects that could help you. They are not using MonoGame.Extended but they might be helpful anyway.

So there you have it. That’s where we are at right now. This kind of stuff is definitely on our radar and we’re actively working to make the library support these features. Welcome to our little community :slightly_smiling:

1 Like

Thanks @craftworkgames!

Thank you for the informative reply. I will definitely keep and eye on what is being developed for Monogame.extended.

Yes, mostly. I am just making sure that there isn’t an aspect of the TiledMap parsing functionality in Monogame.extended that I wasn’t taking advantage of (that I should be). For now, I have tried using an extra Tile layer to represent static platforms. I will mostly likely use another layer for enemy placement (and use IDs of a tile set to correspond to different enemies). I have written a rough wrapper around TiledMap that reads from the appropriate Tile Layer and marks those tiles as platforms. When my characters is moving I will check that information to make sure a tile can be moved in to.

I think I would like to write the a lot of the collision detection myself. I imagine that different games will need different subtleties in their collision management. I am most interest in the camera and TiledMap implementations in Monogame.extended because they feel to my like somewhat game independant aspects of the framework - i.e. they easily could have been included in XNA if Microsoft had chosen to keep it alive.

As you can see I am very early in the development of my game, so I am spending some time planning and designing. I have seen the Platformer2D sample before, but the Monogame Platformer Editor is new to me. Thanks for the links :slightly_smiling:

Yes, that’s intentional. We try to make all of the features in MonoGame.Extended feel like they can be used on their own without overlapping too much. As you say, most people will want to use some of the features and write custom versions of the others.

Good luck with your project. I’d love to see a screenshot when you’ve got something to show :slightly_smiling:

1 Like