I had a lot of thinking about editing levels. Wanting to keep them simple, I’ve chosen good old square tiles solution. First I was convinced, that I’ll save a lot of work by choosing ready editor (like this one: http://www.mapeditor.org/), but after doing some calculations, I’ve decided to make my own.
- Most part of editor’s code will be used in game play code: functionality of those two is very similar.
- Switching between game play and editor will be nice (smooth levels testing).
- It seems that time spent on adjusting design solutions to someone’s editor is similar to time spent on building my own (especially, that game levels will not be sophisticated). Well, reality will verify that.
Time to dive into stream of concrete design thoughts about first version of game editor.
Building a level
Every object occuring in a game’s world, will be composed from little cubes called AtomicCubes. Format of models representing those objects will be discussed another time.
For now I’m assuming, that terrain will be built from Fields composing a grid. Grid’s role will be only limited to alignment.
Building terrain will consist of filling grid with objects, having gridSurface defined. GridSurface indicates how object should be aligned to chosen grid’s field.
An object with a stand surface defined. The stand surface is the surface, defining it’s occupant 3d location. E.g. if tile has a shape of a cube, it’s stand surface will be defined by cube’s top face. The stand surface has it’s default point, needed to indicate the optimal position for it’s occupant. E.g the position to which occupant is heading, when given an order to occupy given tile.
The field has connections to other fields, defining for the occupant the options to change location from tile A to tile B. It does not mean, that tiles have to be adjacent. Types of connections:
- Path. Object is moving from A to B in a straight line in given time (defined by object’s speed)
- Teleport. Object is changing it’s location from A to B immediately.
- Flight. Object is moving from A to B in a curved line, in given time. Example: jump
Inserting objects on the terrain.
Inserting objects on terrain will consist of associating HoldingObject (Field) with StandingObject (e.g Hero).
Irrlicht has a GUI support and whatever its level is, it should be enough for this game editor. I don’t care how Irrlicht gui widgets look like (well, they don’t look encouraging): it’s an editor, it should be functional, not lovely (sfx: the sound of fist hitting the table)! For now I only need:
- Choosing objects to put on the level. E.g the lists of objects.
- Editing attributes of level’s objects.
- Saving/loading level files. First version of levels will be in JSON format.
Conclusions: pseudo-UML class diagram
Basing on above description, I was able do come up with first version of classes to program. Of course reality will verify that, but work should begin with a plan.