5 Replies - 1995 Views - Last Post: 14 May 2012 - 01:26 PM

#1 CosminNegoita   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-May 12

Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 11:42 AM

Hi everybody!

I'm working on a tile based platformer game and it will be something like Knytt, in fact, very similar. This is just for fun and learning purposes as the project is my first XNA and C# project. Till now, I have the basic movement engine and I'm using an array to store the position of my tiles/other game objects.

I'm thinking about building a level editor which will help me design the levels much faster but I'm afraid I'll have to modify the structure of the tile engine a lot.

Below, is a little concept of the level editor, and yes, those are some graphics I made for the game:
Posted Image

The idea is that the map will be structured on layers. As you can see in the screenshot above, there will be 4 layers: tiles, backgrounds, items and mobs.

The tiles layer is the front-most layer, then it follows the game objects and then the backgrounds.

I presume that it won't be achieved using simple Text files, so I think I'll need to use XML files or something like that so each object will have the following structure (just saying):
  • ObjectID
  • Texture Path
  • Position
  • Layer


The game will read this XML/other file and it will build the map according to the data within the respective file. This reading will also be done in the level editor when opening map files.

Now, I'm not very clear how to achieve this and what to use precisely, so any insights and tips would be very appreciated. I wouldn't like to be pointed to "How to make a Tile Engine" tutorials as they are doing things in different ways than I'd want mine to work.

I'm new so if you have any advice and tips, please be explicit.

Thanks in advance!

Thank you very much!

Is This A Good Question/Topic? 0
  • +

Replies To: Building an Excelent Level Edtior - Ideas and Tips

#2 Kilorn   User is offline

  • XNArchitect
  • member icon



Reputation: 1361
  • View blog
  • Posts: 3,534
  • Joined: 03-May 10

Re: Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 11:49 AM

View PostCosminNegoita, on 14 May 2012 - 02:42 PM, said:

I wouldn't like to be pointed to "How to make a Tile Engine" tutorials as they are doing things in different ways than I'd want mine to work.


You want to learn how to build and save your maps to XML files, but don't want to use tutorials on how to do this with XML in order to learn. The best way to learn to use XML files for loading tile maps is to follow some tutorials that do it, and you will learn the intricacies of working with XML. Nick Gravelyn has an amazing tile engine tutorial series on YouTube separated into 94 or so videos that are easy to follow that go through the entire process of creating a multiple layered tile map, saving it to XML file, and loading it into a game. Why would you not want to learn from tutorials that have already done this and resolved the problems that you're going to run into trying to do it on your own?
Was This Post Helpful? 0
  • +
  • -

#3 CosminNegoita   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-May 12

Re: Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 11:53 AM

View PostKilorn, on 14 May 2012 - 11:49 AM, said:

View PostCosminNegoita, on 14 May 2012 - 02:42 PM, said:

I wouldn't like to be pointed to "How to make a Tile Engine" tutorials as they are doing things in different ways than I'd want mine to work.


You want to learn how to build and save your maps to XML files, but don't want to use tutorials on how to do this with XML in order to learn. The best way to learn to use XML files for loading tile maps is to follow some tutorials that do it, and you will learn the intricacies of working with XML. Nick Gravelyn has an amazing tile engine tutorial series on YouTube separated into 94 or so videos that are easy to follow that go through the entire process of creating a multiple layered tile map, saving it to XML file, and loading it into a game. Why would you not want to learn from tutorials that have already done this and resolved the problems that you're going to run into trying to do it on your own?


The reason I'm not really into following tutorials about making a certain thing it's because people can do it in many different ways. I thought that if I'm learning about using XML files, then I'll come up with my own ideas.

Anyway, I think that the most people will point me to Nick's tutorials, so in the end, I think I'll try to follow them. I'm just afraid that it won't work as I'm intending and it will be too complex for my needs.

Anyway, thank you!
Was This Post Helpful? 0
  • +
  • -

#4 BBeck   User is offline

  • Here to help.
  • member icon


Reputation: 792
  • View blog
  • Posts: 1,886
  • Joined: 24-April 12

Re: Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 01:13 PM

View PostCosminNegoita, on 14 May 2012 - 11:42 AM, said:

Hi everybody!

I'm working on a tile based platformer game and it will be something like Knytt, in fact, very similar. This is just for fun and learning purposes as the project is my first XNA and C# project. Till now, I have the basic movement engine and I'm using an array to store the position of my tiles/other game objects.

I'm thinking about building a level editor which will help me design the levels much faster but I'm afraid I'll have to modify the structure of the tile engine a lot.

Below, is a little concept of the level editor, and yes, those are some graphics I made for the game:
Posted Image

The idea is that the map will be structured on layers. As you can see in the screenshot above, there will be 4 layers: tiles, backgrounds, items and mobs.

The tiles layer is the front-most layer, then it follows the game objects and then the backgrounds.

I presume that it won't be achieved using simple Text files, so I think I'll need to use XML files or something like that so each object will have the following structure (just saying):
  • ObjectID
  • Texture Path
  • Position
  • Layer


The game will read this XML/other file and it will build the map according to the data within the respective file. This reading will also be done in the level editor when opening map files.

Now, I'm not very clear how to achieve this and what to use precisely, so any insights and tips would be very appreciated. I wouldn't like to be pointed to "How to make a Tile Engine" tutorials as they are doing things in different ways than I'd want mine to work.

I'm new so if you have any advice and tips, please be explicit.

Thanks in advance!

Thank you very much!



I think Kilorn's advice is really good.

Incidently, I really like your art work there.
I built a basic level editor for a tile engine from my own ideas several years ago. It was a top down view, rather than a side scroller though.

Before you worry too much how to store this thing on disk (text files or XML), you should probably be figuring out how you're going to store it in memory. Personally, I would modify my top-down engine for side scrolling, if I were going to do this.

I'm not sure why you want to do this in layers. Normally, you would use a picture file for the background and then layer on stuff in the foreground, probably in 1 or 2 layers.

Seems to me you would have a layer for the scene and then just draw in sprites over the scene. I would use an array of bytes to store my tiles (you could even make the array for the level larger than the screen). I would have the 256 byte values represent different tiles and tile types. For example, any tile with a value below 16 might be something you could stand on like ground. Anything above that might be tiles you stand in front of. You might even assign a range of tile ids that are items that you stand behind but do not act "solid", so you can't stand on them.

If you wanted to do 4 layers. I would do equal sized byte arrays that "over lay" each other.

Really, the background is the only thing you should need to store on disk for visual purposes. All the other objects would essentially be sprites. But say you wanted to store the state of the game. Perhaps you are using a layers to keep track of the position of mobs where any byte greater than zero in the array means a mob is in that square and the byte number might represent which mob it is.

The more I think this through the more I think I'm starting to understand what you're up to.

Then you could have another byte array that stores positions of items and any square with a byte value > 0 has an item in it with the byte value being the item number.

So, if you have a grid that's 512 squares wide by 64 squares tall, then you would have an array for each layer that is 512,64 in size and stores byte values.

Storing it on disk could probably be done server ways. You could use a text file and just store all the values in each array with Carriage Return Line Feed at the end of an array row and a comma between each array element. You might even put in a header before each array, so that you can jump straight to the values you need for a given array. You could store each array in it's own file or you could store them all in one file.

But the only reason I can think of that you would store positions for mobile thinks, like mobs, on disks would be to save the game during game play so that you could restore the game back to the previous save state.

If you make people restart a level at the beginning any time they reload, you probably only need to store the data for the background/scene and maybe the item placement array as well.

Anyway, I would start developing my game by just defining an array(s) and pluggin numbers into it by code. I wouldn't worry about the file storage on disk until I kind of had things working.

Since every tile would have a byte value in that array you could use that for textures/sprites. For example, in my background array, maybe 2 is dirt/ground. I would something like an array or maybe a list to store texture names according to their ID number, so that I could go lookup which texture/sprite needs to be drawn for that tile. I would probably have a seperate array or list for each layer.

You could do that as a seperate 2D array of ID, Texture. Or you could do it as an array of Layer, ID, Texture and store all layers in one array yet maintain seperate textures for each layer (since an ID of 64 in one layer might have a different texture than 64 in another layer).

Again, this could be stored the same way in a text file, or you could use seperate text files for every array. When you get ready to load the game you just load up each array using the data in the text file to populate every array.

Once you have a text file format for loading all your data in, you can start working on a level editor. I did my level editor in Visual Basic. You could do it in any language. You could build your level editor in C on a Linux machine. It doesn't matter because your level editor is just going to build the text file that loads data into your game.

I would probably build the level editor in standard C# with Windows Forms (I used VB with Windows Forms for mine). I would then build something that allows me to lay out the tiles (and shows me what I'm laying out) and then saves the results to the text file format that I created for the game.

Obviously you'll have to change both the game and the level editor if you makes changes to the file format. But otherwise they can be pretty seperate from one another.

Anyway, I really like your artwork and choice of colors. Good luck with it!
Was This Post Helpful? 1
  • +
  • -

#5 CosminNegoita   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-May 12

Re: Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 01:25 PM

Thanks and that was quite a long read, but yeah, you did understand what I want.

The thing is that I already have an array where I place numbers, and then load textures according to that number.

The reason why I wanted layers is because for example, I will have dirt walls, so I'll need to pass through them. Say that I have number 9 on map[i,j]. Then, I would want to add a tree in the same position, but have the wall behind it. I can't add 2 objects in the same position.

That's why I need to kinda store game objects in different arrays according to their object type.

But then I thought that a text file with 3 or 4 arrays(for layers) would look messy. Also, maybe it will be kinda difficult to read from that text file.

Anyway, your words are really helpful and I'll do further research.

And thanks for the compliments :)
Was This Post Helpful? 0
  • +
  • -

#6 Kilorn   User is offline

  • XNArchitect
  • member icon



Reputation: 1361
  • View blog
  • Posts: 3,534
  • Joined: 03-May 10

Re: Building an Excelent Level Edtior - Ideas and Tips

Posted 14 May 2012 - 01:26 PM

I've built a tile engine before using WinForms and XNA, basically just having a graphics device control being drawn to a WinForms application. It was based loosely off of Nick Gravelyn's tutorials, and used the WinForms sample from the AppHub, which contains the Graphics Device Control. My tile engine actually utilized multiple layers for a specific purpose. One layer for the base layer, one layer for details such as plants, trees, barrels, and other nice pieces of scenery to add to the feel of the level, and one level for collision. The collision layer was just an empty tile, denoted by -1 in the array, or a solid black image, denoted by a 0 in the array. It was also top down, due to my fascination with RPG's pretty much my entire life. I think I've got a screenshot here somewhere on the forums of it, but I can't be completely sure. I never got around to finishing it and actually utilizing it in any games, but I've always got it in a working state to come back to at a later date if I need it. My levels were loaded using an XML file that kept track of the tileset that I was using for that particular map. Labelled each layer in the map, and loaded each layer in order from base layer, to details, to collision.

I also used an Image control added to the right side of the WinForms application that displayed the entire tileset that I was currently using. You'd simply click on an area of the tileset and it would select a tile from the tileset to use to draw on the tilemap's current layer. I had plans to one day allow you to use different tilesets for each layer, but other projects got in the way and I kind of lost interest in it.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1