[Twisted-Python] "3D Game Using Twisted?", or: "Ach du lieber..."

Derek Simkowiak dereks at realloc.net
Wed Mar 13 21:14:34 EST 2002


	Hello.  My name is Derek Simkowiak, I've just been introduced to
Twisted by Sean Riley (sean at twistedmatrix dot com).  I'm using (and now
contributing to) his PyUI widget set for my 3D game engine.  When I told
him I still needed to write the networking code, he pointed me here.

	I wanted to introduce myself, ask for some general guidance about
a network protocol, and point out that the documentation titled "The
Basics" at

http://twistedmatrix.com/page.epy/docs/basics.html

	results in "no such page", which really sucks for somebody just 
getting started (like me).

	First, a little bit about my game engine, because it's the type of
thing you twisted Twisted people might be interested in:

o  OpenGL for rendering
o  SDL for event management
o  Quake2 BSP map rendering (many more model formats to come soon)
	- includes almost all of the Id BSP culling tricks
	- includes fully-functional collision detection using the Q2 
"bloated planes" algorithm, as figured out by Kekoa Proudfoot

o  Complete in-game GUI over the top of the 3D world, including 
transulency, using the PyUI widget set.  Screenshot at:

http://www.realloc.net/~dereks/targa_pyui1.jpg

	Also see the older shots at:

http://www.realloc.net/~dereks/commputers/my_code/targa/


	Also, the big piece that you may like: I've recently refactored
the whole damn thing, and with a little help from SWIG my "engine" is now
nothing more than some Python C extensions.  My "main event loop" is just
a simple Python script, and because all the [bottlenecking] rendering code
is still C, I get the ~70 FPS I was getting when the entire engine was
pure C.  But now I have Python at my disposal, mua ha ha.  (Also, note
that all the libraries are cross-platform.  I'm developing under Linux,
but eventually this thing should run under MS-Windows, Mac OS X, AmigaOS,
and even PlayStation2.)

	The big pieces I have left are the enemy A.I. and the networking
code.  This is a client-server engine.  The light at the end of the tunnel
is load-balanced Linux cluster (using LVS) serving up a persistent, 3D
world (ala' PlanetSide), and maybe even me making some $$$ from a few
hundred subscribers paying $5/month.  Now you see where Twisted fits in --
I'm basically shooting for twisted.reality in real-time 3D.

	My concern is regarding bandwidth.  My game protocol will be
similar to the Quake2 protocol, meaning huge lists of 'entities' are
updated with position and orientation data as often as possible.  Such
generic position updates will be done with UDP, and 'critical' packets
(such as damage, explosions, jumps, messages, etc.) will be done with TCP.  
In summary, every single byte of network overhead matters -- nay, every
BIT matters (npi).

	So I've browsed through the API docs, but I don't have any context
to know what I'm looking at.  I'll be downloading and installing the
source soon, but in the meantime... any advice?  

	Is there any particular package I should be looking at (other than
twisted.internet)?  Does Twisted's networking code cater to somebody who
needs to, for example, do bitshifting and compression to absolutely
minimize the bandwidth requirements?  What approach would you take?  Note
that, using PyUI for the GUI and [possibly] Twisted for the server, I want
to have things like in-game "IRC/ICQ", in-game "emails", and also in-game
"voice chat" ala CounterStrike 1.3.  Other wild ideas include in-game
video conferencing, and dynamically-downloaded bits of Python code that
would act as all-new, not-previously-imagined entities.  (Note that by
"in-game" I mean the 3D world is rendered, and the email/IRC/video client
application is rendered on top of the 3D world with some translucency.  
The idea is to keep the player immersed.)

	Any advice is greatly appreciated.  If anybody else is using
Twisted for something similar, I'd love to hear about it.


Thanks,
Derek Simkowiak
dereks at realloc dot net






More information about the Twisted-Python mailing list