Game Design, Programming

Second Artifact – Level Editor (kind of)

 

Another week, another Artifact. This time it will not be from the game itself, but a tool to make it easier to create the level.

 

So, I have been working on a Level Editor for our game, With Intent. The reason for having it is so that it will be easier and faster to build the level with all the walls, furniture’s, doors, guards and their waypoints, start- and end-positions. Without an editor we would probably have to input all those coordinates, degrees, etc., manually, in a text file.

 

I chose to create the editor in C# as a Window Application Form. It was an easy transition from C++ to C#, it took a couple of hours to get the hang of, but after that I have had no bigger issues with it. It has been fun to learn a “new” language, even if it is like a blend of C++ and Java, two languages I have worked a bit in.

 

All positions, numbers and degrees are saved in a lot of different Lists<>. Those lists work a lot like Vector<> from C++, except that it seems like you have to “new” them to use them, at least I couldn’t find any way to work around that. And now that I’m writing this I’m realizing that I have not “deleted” a single one. I really hope that it is done by automatic in C#, like in Java, and not like C++. Otherwise it would be kind of embarrassing to forget something like that…

 

Robin found out what was up with our bugged walls, those that could be seen through if the player got to close to them. It had to do with X being much larger then Y, or vice versa. So I did so the editor, when it saves to the files, “cut” the walls in smaller squares then very long rectangles. I thought this part wouldn’t be that hard but I had a hard time concentrating on the task so it took more than the three hours I had predicted. I’m up to six hours now and is still counting.

 

The first thing to do after the editor have been loaded is to load an image. This image will be the mold to see where everything should be. The next thing to choose is what to place, walls, guards etc. Some things, like the guards and tables, will also need a degree to say in which direction it will be facing when it is created.

 

When the Save button is pressed it will save everything in text files, that can then be read by the game to create the objects in game. The picture shows a small part of the code that saves all Lists in text files.

SaveButton_code_part

Standard

One thought on “Second Artifact – Level Editor (kind of)

  1. A highly interesting post for all beginner programmers!

    I understand the reason for using an editor but why did you focus on making your own level editor? Did you weigh the time it takes to learn a new language
    and making your own editor compared to using an existing one like for example Tiled (http://www.mapeditor.org/)
    I’m myself interested in making my own editor for learning purposes is that why you made your own one perhaps?

    Is the Editor run as a seperate program? Does it load in different sprites as well for each item? A window appication form doesn’t say much. Those can look different from one to another. It would be nice to see a picture of the level editor so its easier to understand.

    Easy to read and well written but I would have wanted a little bit more info and some more pictures. I liked the way you described the save button with a picture. It gives so much more and I also got my first glimpse of C# and it doesn’t look so much different from C++.

    A tip for your worries about memory leaks you should use a memory leak detector like (http://vld.codeplex.com/) for C++
    I’m not sure it works for C# but there is probably something similar out there.

Leave a comment