Python in game development?

Sean Wilson newsgroup at neutron.globalnet.co.uk
Thu Jul 20 10:33:13 EDT 2000


Hi,

> From a game programming perspective, you can probably consider Python to
> be dirt-slow, though. The trade-off is a lot of power for speed, but
> that power can help you gain back speed because you can be a lot smarter.

Before I started trying to write my own scripted language I tried to find
some tutorials and articles on them but couldn't get them anywhere. Someone
directed me towards python but I couldn't find anything about the virtual
machine it uses. How does it work and why is it so slow?

My system is extremely simple and only allows assembly style instructions
but I cannot really see how it can be made faster. Using the 'Move
<Direction of movement> <Number of steps>' command, the following list of
integers are produced for Move Up 3 (where capitals are constant values):

CMD_MOVE
CONSTANT
DIR_UP
CONSTANT
3

I just have a big 'switch' statement which the first integer is sent to,
with each command having matching 'case' statement. The relevant command
code then reads in one parameter at a time, moving the current integer
pointer in the script forward after each. The parameters are then send to
the C++ Move function to be executed.

I found a tutorial on Flipcode which used a stack machine but this seems
very slow compared to this approach. One big disadvantage though of my
approach is that I'm allowing no compound statements (e.g. Move Up (1 + 2)),
but this isn't a problem since the game is based on a 2d tile map.

What other methods are there? How do professional games such as Unreal do
it?

Regards,

Sean Wilson
http://www.users.globalnet.co.uk/~neutron/programming





More information about the Python-list mailing list