Instantiating and initialising C++ with embedded Python
Morfeas
greek_bill at yahoo.com
Tue Sep 17 16:12:37 EDT 2002
Hello,
I'm developing a game in C++ and I've come to a point where I think I need
to use a scripting languge (and why not python?!).
I have a nice C++ class hierarchy that does all sorts of things. I need to
be able to create (i.e. instantiate) and initialise a bunch of objects at
run time. For example I need to do the following (in pseudo-code) :
if (car jumps over obstacle)
{
award points to player;
}
I could hard-code this with C++, but I'd like the flexibility of doing this
only for cerain game levels, etc.
Since I've only started reading on Python, can you please tell me if the
following is right :
1. My main program is in C++, so I need to embed the python interpreter.
2. I need to allow python access to my C++ classes, therefore I need to
extend the embedded interpreter.
I think I'm ok with doing (1), but not so sure about (2). I've been reading
the python documentation, but they seem to focus on C rather than C++. I
believe I need to write some python-friendly class definitions, etc.
Can someone give me some of the following :
a) a brief description of the whole process
b) some code examples
c) suggestions about useful tools
Thanks,
Morfeas
--
www.freecfm.com/m/morfeas
More information about the Python-list
mailing list