[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame



john fleming wrote:
if you think about that, it's not such a crazy idea. games like Quake3 and Unreal are written entirely in a high level bytecode interpreted language which runs on a C engine.
quake3 uses regular c. the development tools for quake3 come with a modified version of the old "lcc" compiler. this produces relatively well optimized C code, and was hacked into creating custom bytecode. then internally, Quake3 has a virtual machine that runs the code.

unreal (and friends) use unrealscript which is a custom scripting language. it is actually pretty powerful and includes some unique structure for 'game state' classes. they are kind of like regular classes with something like python generators built in at a lowlevel, much easier to for creating stateful game objects than regular python classes. unrealscript has its own compiler, but i'm not sure how much optimizing it does. and again the unreal game engine has a virtual machine. there are plenty of sites with lots of docs on how to use this language.

both these languages have a bit of a speed advantage over python. like c they are strongly and statically typed, so optimizers can easily make some big optimizations to the code. i'm sure they run quicker than python, but on the other hand they already run plenty fast. the great thing is that game mods for these engines will run on any platform, since they are compiled to bytecode.

what is impressive is that almost the entire game runs inside these scripting languages. the c engine deals with the intense stuff like rendering, pathfinding, dynamics, etc. but the actual 'game' is entirely in bytecode. the code for these games is freely available (not quite freely distributable) so you can go download the sourcecode for the entire game and check it out. "class Shotgun(weapons.Hitscan), etc"

i'm most impressed with the unrealscript language, it is a simple and clean OO scripting language. there is a single "object" class that everything derives from, weapons, players, projectiles, even objects on the map.

i remember when quake3 was recently released, people had been able to recompile all the 'quakec' source into actual x86 windows dlls. you could swap out the bytecode with the platform code. there was about a 10% speed difference between the two. i never got quite that much difference on my machine, as my graphics card was more of a bottleneck than the cpu time.

a long time ago i remember someone took the now gpl quakeworld source and swapped out it's custom 'quakec' interpreter for a python interpreter, then translated all the 'game code' into python. just a 'for fun' type project i believe, but i'm not sure if any interesting conclusions were ever reached.