Tales of the Rampant Coyote
Ye Olde Archives. Visit the new blog at http://www.rampantgames.com/blog/ - and use the following feed: http://rampantgames.com/blog/wp-rss2.php


(  RSS Feed! | Games! | Forums! )

Friday, November 10, 2006
 
TGEPlus: Two Game Engines In One!
So what do you do if you have two game engines that nicely complement each other, but you don't have the capacity to use them both? Well, in my case, I smashed the two of them together to get the best of both worlds. It helped that the two engines were both variants of the same technology and were, in fact, originally designed to coexist peacefully.

I'd been lamenting the fact that as cool as the Torque Game Builder (GarageGames' relatively new 2D game engine) is, I really didn't have an upcoming project that would take advantage of it. Sure, I'd written a couple of small, non-commercial games with it that helped me understand the system, but realizing that it'd be 2008 before I could even THINK about putting it to use in a major project.

On the other hand, on my wish list of features for the Torque Game Engine has been an improved UI editor and UI tools. Torque's GUI tools, out-of-the-box, are fairly spartan. Sure, they get the job done, and allow the creation of some fairly powerful interfaces. In a straightforward, build-a-UI-with-MFC kinda way. But if you are going for flash - animated menus, elements fading in and out, controls that responded to changes in the game, or anything else really DYNAMIC --- well, it's time to crack open the ol' C++ engine again and extend a class. Or, at the very least, create a dozen artwork variations to deal with the fact that you can't rotate or mirror UI elements.

For an upcoming project (not Apocalypse Cow), this is something of a headache. It has a LOT of dynamic UI elements, which need to slide around, rotate, and fade in and out on the screen. If it weren't for the fact that the principle gameplay needs to take place in a 3D environment, I would have chosen to go with TGB as a solution, as it's perfect for that kind of thing.

The answer was to try and integrate the two. After all, TGB was built over the top of Torque, right? Searching through some posts on the forums, I found a comment by Josh Williams (link HERE if you are a TGB owner) which raised my hopes - though it was suspiciously 18 months old:

'Well, here's a mega-quick guide to putting T2D in TGE:

1) Copy the C++ source files in the engine/T2D directory over to your TGE
project (copy them into your directory, and add them to your compiler
project)

2) CompileAnd there ya go. :)

We designed T2D specifically to be drop-in compatible with TGE like this.
Maintaining this constraint was quite painful, design-wise. There were many
times when either Melv or I said "man, forget Torque compatibility, this sucks."
Luckily though, when one of us said that, the other guy was like "come on...
this is important" and then we figured out a smooth way to keep the code clean
but still do what we wanted from T2D's p.o.v. So, we pulled it off, and it's
extremely easy to integrate these two projects now. Should always stay that
way.'


Well, sure, but that was back in Torque 1.3 & ancient early adapter "Torque 2 D" days. Could it be that easy?

Well, no. There were some minor compile issues. Still the project only took me about twenty minutes, including time to go get a drink from the fridge. When I tried out the resulting code, the results were hopeful but.... glitchy. Still, it looked like I had the capability to put in automated, animated UI elements in my code. It would need a bit more work, but I was optimistic.

Later, Gary Briggs popped on with suggestions from his own success combining TGB and Torque 1.4. The thread, if you have access to the forums, is HERE. There were a lot of little things that needed to be fixed.

I spent some time integrating in the new changes (total time: Maybe a little over a half hour to hunt everything down, copy them over, make the changes inside files, and add them to the project in Visual Studio.) The result?

Well, the resulting executable wouldn't run the TGB Editing tools. Okay, it would run it, but would pop open an error. I should probably go through the whole thing and do a DIFF to see what else needs to be done.

However, I also ran a couple of the games I'd created in TGB, substituting in my new executable (which was also being merged into the changes I've been making for Apocalypse Cow) instead of TGB. The result?

Flawless execution.

FLAWLESS!

Granted, my games weren't exactly stress-tests of TGB. But my resulting project, which I have dubbed "TGEPlus," grants me all of the enhanced UI functionality I anticipate for next year's game. Plus, I intend to use it where I can for Apocalypse Cow. 2D particles in screen-space. Animated menus which slide in and out of the screen rather than just "popping" in and out of existance. Maybe little 2D cows that peek over the edge of the screen with signs that read, "EAT MOR PEEPLE."

Not bad for only one hour of effort. I'm not ashamed of taking advantage of other people's hard work. That's one of the many advantages of using a popular, third-party engine. Kudos to GarageGames for trying to keep them compatible.

Now, the cons:

* Buying a second Torque engine may be a bit too pricey for people who are only interested in enhancing TGE's UI functionality.

* As I mentioned, my merge is still not perfect - it doesn't work as a replacement for TGB with the tools suite. Some more work needs to be done - though I don't know if it's a priority for me, personally.

* My final executable clocked in at around 4.9 megs for the release version executable. It had some additional code from my current game, but a small enough amount to be in the noise. TGE comes in at a pretty hefty size to begin with, and so the addition of the TGB library may not entirely tip the scales - but it's a definite impact when considering file size for a downloadable game.

Again, many thanks to Gary Briggs and the GG team. The effort is appreciated!

Labels: ,



Did you enjoy this post? Feel free to share it: del.icio.us | Digg it | Furl | reddit | Yahoo MyWeb

Comments:
Very interesting stuff. I bought TGB a few months back but haven't really played around with it much. In fact, I'm lagging a version or two behind so I need to update my copy and give it a go. I have a project in mind that I'm definitely going to do in TGB but that's a ways down the road.

Anyway, I'd definitely agree that the world and UI editors can use big improvements.

The UI editor in particular is in a fairly sorry state. It's functional I suppose but the resolution issues alone often make it a chore to use. I've gotten to the point where I'm just using it to "rough out" a UI and then hand-editing the .gui file just to avoid screwing something up.

The world editor is in a better state but needs some minor functionality added. Namely, snap-to functions for objects (ideally something that can snap objects to the terrain or to another object) as well as some quality-of-life fixes for the editor UI itself (specifically the ability to resize the field name section in the object inspector; as it is, field names that are too long are cut off so there's no way of knowing what property you're changing).
 
This is very cool. I haven't seen your thread, so I'll definitely go and check it out.

I completely agree that the UI editor is one of TGE's biggest flaws, but I've become more comfortable with it. I haven't had a big problem creating UI elements that fade in and out, though. Vespers uses text buttons and PNGs that fade in and out on the main menu screen, and it didn't require a huge effort. But the fact remains that it required getting my hands a little dirty, and for something so basic and simple one might wonder why it was necessary.

I'm in the same boat as you; I have a TGB license but there's no way I'll be able to start on a TGB project for a long while. But I'm envious of it and I'd love to do something with it.

Is it possible to isolate the UI code and just incorporate that into TGE, or is that too dependent on other TGB code?
 
I would LOVE to see TGE's editors get up to the same state that TGB is in. But the very complexity of 3D and the efforts to keep the engine generic may stand in the way of that ever happening. Though improvements could be made, certainly.

TGB keeps the same UI editor as TGE - but for the most part it seems like people ignore the UI Builder and just construct their own with the regular 2D tools. At least that's the impression I get. I'm actually PLANNING on using TGB as my UI editor for the next game :) And then just importing the files over.

So no, no separating the UI elements from the rest of TGB. I'm basically using TGB *AS* my UI.
 
I was wondering how much code the two products shared; I figured the base maths library at least must be duplicated.

I'm hoping for better Mac tool support before I consider dropping the extra change on Torque.
 
The two engines share a LOT of code. I'd say about 75% - 85%, but I haven't checked file-by-file. Really, TGB is simply Torque minus some extraneous stuff plus a lot of cool 2D functionality, plus some really nice tools.
 
Post a Comment

Links to this post:

Create a Link



<< Home

Powered by Blogger