Blitz3D Newbies: Creating a Level Editor (Part One)
by Qox - No Enemies Development Team

Nowadays almost every game has an editor of some sort, where users and players can create levels, mods, maps, and even complex scripted scenarios. This tutorial will explain how to make your own editor using Blitz3D and BLUI. You can get BLUI from here. BLUI is my favorite GUI, and I will be using it throughout this tutorial. If you would rather use another GUI that you already have, go ahead, although the functions might not be the same. I'll leave it up to you to translate it.

This is part one of a series of Level Editor Making tutorials I will complete. This first part will get the basics down, while the second part will go into more complex concepts.

Setting Up
You set up your 3D level editor as you would any other 3D program - initializing a camera, a light, setting graphics mode, setting the buffer, etc. But also you must Init and Include BLUI. Here's how I set up my editor:



Next we'll make the actual GUI, and then move on to writing the main loop code.

Designing the GUI
I'm not going to go into a lot of detail about the BLUI functions, as that is not the main point of focus here, and the functions are self-explanitory themselves. I will, although, comment most of the other code. Here is how we'll design the GUI:



Next we'll set up for what we'll be starting in Part 2 of the tutorial.

Setting Up
We've only got the butter done - now it is time for the meat and potatoes - that is scripting, and actually making the level editor make a level. ;) First of all, we need our platform type:



The x, y, and z is the platform's position, the mesh is the mesh it will be loading/creating, and "tex" holds the texture. Feel free to add other parameters to this type, if you'd like.

We'll also need some sort of flag to tell us the position. It should be parented to the camera, like this:



The cursor positions are the current positions of the flag. You could modify the numbers to make the camera move more slowly, or faster. For now, we'll stick with what is above.

Next it is time for the GUI events. We must check to see which menu item has been selected, and then choose an event for it:



That will be it for today's tutorial. Keep watching the tutorial section - expect your saving and loading functions to be working soon!

Conclusion
We'll continue making our editor soon, with fully-featured loading/saving, object making, and more. But now, for those of you who don't like to read everything in separate pieces, here is the current editor code in full:


Have fun, and be safe! ;)


For a printable copy of this article, please click HERE.


This site is Copyright© 2000-2004, BlitzCoder. All rights reserved.