lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I have created a new "base" build of my game engine that includes only the bootstrapper, scripting services, and a couple of support libraries. It was an interesting exercise, I think the code as a whole is much cleaner now as a result. What it all amounts to is a performance-oriented Lua distro with a formalized extension system. In order to compare apples to apples, so to speak, I created a minimal wrapper for SDL to run Thatcher's "Meteor Shower" game (another interesting exercise, see below).

Before I ramble on too much, you can get it all here:

With this disclaimer: this was a quick refactoring of development code. Lots of stuff is missing, but what's there should work.

My engine architecture is component based (a la COM, Unreal, etc.) and the extension system reflects that. If you look at the previous version of the engine you can get an idea of where I'm heading with it. Writing the SDL wrapper was a little clumsy but I think it would be possible to adapt toLua or swig to write the code, something I might look into. Until I saw Thatcher's game I didn't realize how useful a vanilla SDL/OpenGL binding could be for prototyping stuff.

One thing to note is that the extension system is independent of the scripting language. By replacing script.dll, I could script with Python instead of Lua, without having to rebuild anything else (but why anyone would actually *do* that is beyond me ;) )

In order to mitigate the heap-intensive nature of scripting I put together a new memory manager that pools same-sized allocations together. On my development machine (700MHz) the game was locked to (refresh rate/2) so I wasn't able to measure any improvement. On my wife's 450MHz, Thatcher's original version ran at 19fps, while the F4 version got 24fps.

The bootstrapper includes the start of an interactive console, but it's not operational yet (commented out in main() for now).

Getting Thatcher's code to run was really a pain. I ended up having to cut-and-paste a couple of lines at a time in order to be able to pin down missing functions and incompatibilities. A line like:

  if (event.type == SDL_QUIT) then

turns into 'if (nil==nil)' when neither object has been defined. There were a lot of similar issues, and without an interactive debugger the easiest way to track it down was reduce the code. I'd hate to have to do this for a larger project! I think I'm going to add hooks into the scripting service to allow it to talk to a debugger, maybe I can create a plugin for Scintilla or somesuch.

Okay, enough from me for now. Obviously I can go on and on about this stuff.