Time to build the Map Editor!
Hi again!
If you remember last time, we were in the process of defining what was important for Little Ninja’s new Map Editor. If you haven’t read the last article, it’s a good idea to take a look at it since I’ll be taking off right where I left it
Map Terrain Design (Part 2)
Last time we were overviewing the different terrain angles. After taking a look at my favorite platform-adventure games, I decided to keep three types of angles, remember?

One may think that most platform games have a wider array of possible angles. However, in fact, I came to realize that a great number of games only use the 45° and ~26° inclination — Cave Story or Metroid, for example.
Now that I have chosen the three types of angles, it’s time to choose the different terrain directions. Fortunately, this is a very easy choice as tiles can only be transformed (rotated or flipped) into four different configurations, creating the following set of tiles:

Now that we have terrain type, angle, direction, we’re all set to start making our Map Editor™ ! Before starting, let’s do a test-run on our current terrain:

As you can see, the combination of tiles allows a quite versatile design, while keeping it “simple”. While our Ninja trap does not look too smooth, remember that this is our mask! Further addition of foreground tiles will do the trick, believe me (I can’t wait for Yuan to give me some tiles). Actually, Yuan has already started drawing the prototype sprite art for Little Ninja.
Map Terrain Structure Overview
So, let’s review what we have until now: each tile contains information about direction, angle, and type of terrain. From a technical side, I decided to use:
2 bits for direction (2 ^ 2 = 4 combinations)
5 bits for angle (2 ^ 5 = 32)
5 bits for terrain type (2 ^ 5 = 32)
That gives us a total of 12 bits. In order to fill 2 bytes (that is, 16 bits), we have 4 bits left: we’ll use them for special cases. So, what’s a special case? I don’t know, and that’s exactly why I’m saving those 4bits.
For now, the only important types of terrains are empty and solid tiles (character collides against them), with all the variation of angles and directions. This is my tile palette for now:

Our transparent color is always magenta (aka: ugly pink), but from now on I’m probably not gonna use it because, as the name implies, it IS ugly. Anyway, our Map Editor’s interface is quite simple: a simple editor where you choose the width and height of the map, select a tile from our tile palette, and draw tiles on the actual map!
Anyway, the editor is finished (for now) and here’s a video:
Oh, I also added a grid as well as a foreground grid. Nothing complex but certainly useful. The Save and Open functions are crucial since we need to load the map on the actual game code. It’s just a simple file with information about each tile, as well as the width and height of the map. I’ll be using my test.map for the next part.

Anyway, that’s it for today. Next time I’ll be loading the actual map on the game, and start adding the most basic player controls (walk and run). The current map editor clearly needs a lot more work, but that will come later
What do you think about it? Please let me know if the post was too long or simple, etc., or if I should describe the programing-related issues more clearly. Thanks!




November 19th, 2008 at 3:14 pm
Nice! What programming language do you use to code the game and tools?
November 19th, 2008 at 7:52 pm
The game is programmed in C and C++, while the tools are programmed in C#, since it’s overall faster to program using a high level language. Before Wind and Water, I used Visual Basic (since Visual Studio.net had not been invented yet) for the same reasons
November 19th, 2008 at 10:53 pm
I have been really enjoying your these articles, I think perhaps a secondary blog so you can have one for posts like this, fairly simple, and another for the coding aspect, in turn the second blog would be much more complex, for experienced coders who are interested in what your doing. I think this articles length is just about right, and the time between posts seems to be pretty good too.
Abe
November 21st, 2008 at 11:13 am
Yes, in fact some articles could get a little too technical for the average visitor, so I’ll try to categorize and customize the blog for a more easier navigation between Yuan’s posts, my usual design posts, and more technical ones.
Thanks for the suggestions
November 27th, 2008 at 5:08 am
I’m interested in game programming and I think that would be great more technical posts. As a beginner I’m always looking for some techniques and code to learn.
November 30th, 2008 at 8:09 pm
[...] how to design the most basic parts of a platform game engine. On our last post, I finished a simple Map Editor, now it’s time to put Ninja Stick Figure into [...]
February 9th, 2010 at 10:12 am
what program do use?