Using Python to script a game?

Kevin Altis altis at semi-retired.com
Sat Jun 15 07:46:03 CEST 2002


Freedom Force is the game you're probably thinking of that uses Python as
the scripting engine.

I blogged about it here:

http://radio.weblogs.com/0102677/2002/04/27.html#a55

ka

"Gerhard Häring" <gerhard at bigfoot.de> wrote in message
news:mailman.1024106376.21850.python-list at python.org...
> * Ben Blonder <ben at sourcecod.com> [2002-06-14 18:18 -0700]:
> > I'm writing a 3D naval tactics in C++ for the Mac. I'm planning on
> > having all the object behaviors, movements, and AI controlled through
> > a scripting layer. The scripts would be text files the game would
> > parse and then carry out actions. All the scripts would be read at
> > runtime, not compile time, so they'd all have to be interpreted.
> >
> > For example, I might have the C++ code
> >
> > class foo {
> > public:
> > int x;
> > void print() {
> > cout << x << endl;
> > }
> > };
> >
> > In the scripting system, there would have to be some way to create a
> > new foo object, define x, and then call print() while the user was
> > playing.
> >
> > Can I use Python to accomplish this,
>
> Yes. And it would be a pretty good match, too. There's even been a
> commercial game that uses Python for internal scripting, its name
> escapes me, though.
>
> > and if so, can you point me to some tutorials on integratring Python
> > with my existing code?
>
> Python's documentation has (now) good documentation about it's C API.
> Python's API is _C_, though, not C++. There are several C++ wrappers for
> it than can simplify the integration a lot. My personal favourite is
> Boost::Python. http://www.boost.org/ As a C++ developer, you might be
> interested in the other free libraries from Boost, too. What these
> people accomplish is really amazing!
>
> Gerhard
> --
> mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
> web:    http://www.cs.fhm.edu/~ifw00065/    OpenPGP public key id AD24C930
> public key fingerprint: 3FCC 8700 3012 0A9E B0C9  3667 814B 9CAA AD24 C930
> reduce(lambda x,y:x+y,map(lambda
x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
>
>





More information about the Python-list mailing list