So, I’m using Maratis. It’s a great little 3D engine, it does everything I want, or close enough. Why would I be considering integrating an existing 2D engine with it. Surely that is a lot of work for no real reason.

Well, yes and no. Maratis does one thing really well and that is that it’s very easy to set up a 3D scene and have something working. I would even say it does it more or less as well as much more mature engines like UDK. What it doesn’t seem to do well is 2D.

“You’re making a 3D game, why are you worried about 2D at all?”

I’m not as such. But almost every game, whether 2D or 3D has 2D in it somewhere. Menu systems and heads up displays (HUD) are two common offenders. Maratis has an inbuilt UI system for user interface, but it’s currently not exposed to (game) plugin development and also, it’s entirely code driven. That’s great, if you have a coder who is also the artist and designer, but, anyone who has seen my art would understand, I’m no artist.

The other option in Maratis is to do the UI in a 3D scene and render it without perspective on top of the actual 3D scene. This is actually an acceptable solution as it’s more or less how any 2D system would do it anyway, but having to do the layout in a 3D editor seems more than a little clunky, and a lot of 2D designers/artists are unfamiliar with 3D stuff, making it a pain in the neck to use for all concerned.

Having said that, I’m actually pretty good at UI layout. But it’s usually a tedious to-ing and fro-ing between the person who made a mockup and myself “move this 2px up and 1px to the right” etc. What would be ideal is if the artist/designer who made the art in the first place could just save what they’ve done in some sort of format that the engine could open up and use. Then a programmer can tie in any functionality into the game, either before or after the 2D work has been done.

The first thing that I should mention is that this has been done a lot of times. A lot of AAA games use Scaleform, which basically renders a Flash swf on top of the game. That, in itself is derived from the public domain gameswf library which I’ve had some experience with. I decided, much as flash is widely used, I would keep away from it for now.

Enter löve2d. It’s an amazing little 2D game engine. All the development is done entirely in lua. It already has several pretty nice looking UI libraries. Now, it’s more complete than we “need” for a UI system in Maratis, it’s unlikely that UI will ever need Box2D for example, but there’s no reason to take it out as such. If we could get love2d integrated into a Maratis plugin, we could then maybe use love files for our UI, or maybe even do something a little more fancy.

Now, the astute reader will notice that we’ve not actually solved the problem here. A programmer will still have to write all the love UI code, right? So why not just do it in MGui in the first place? And we’re involving another language which we potentially wouldn’t have a dependency on. (ok, Maratis already has lua inbuilt and all the examples are lua, but you could do the entire development in C++ if you wanted) So again, why integrate this whole engine, when it’s not making any difference?

Well, I think it will. Right now, every love UI library requires the layout to be done in lua. Which is no good. I recently set myself a little task to see how difficult it would be to write a data driven UI system in lua. I have to admit that it’s not very nicely written, yet, and that it’s nowhere near complete. However, it’s a proof of concept at this stage. I even started working on an editor, although, I’m still in the design stage of how that should work. If anyone wants to check this out, I’ve stuck the work onto github. Would love to get feedback on it.

The main thing that I think is a really great thing for this is that, on every project I’ve been on, we’ve needed custom UI elements. It’s unlikely that any UI system has covered every possible option for what you would need. If it has an editor, the chances are it’s also not flexible enough to allow you to create your own elements. If the UI code is all in lua, as lua is interpreted, the editor can load the standard UI elements itself, then look in the project and add the definitions for any custom elements. Basically the editor becomes as flexible as the UI system itself. That’s the idea anyway.

The other benefit of lua is that it’s incredibly quick to prototype things in. When I’ve written custom element definitions in C++, it’s required anything up to a few hundred lines in source and header files as framework, before it actually did anything. Ok, that might be a bit of an exageration, but when I was creating new elements in lua it was much quicker.

So, in summary. Using Löve2D within Maratis is overkill. It’s also likely to be the quickest and most flexible solution to 2D UI layout, without resorting to Flash.

Or does anyone else have any other thoughts

Leave a Reply

Your email address will not be published. Required fields are marked *