Using Python to script a game?

Ben Blonder ben at sourcecod.com
Fri Jun 14 21:18:47 EDT 2002


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, and if so, can you point me to
some tutorials on integratring Python with my existing code?



More information about the Python-list mailing list