Python graphic engine calling C++ game engine and models

Hi my teammates and I are developing a small RTS game for our class project. We have under a year, and we’re close to coding. We intend to do our project in C++ and use Panda3D. We’ve noticed how simple and easy it is in Python but we would like to code parts of this game in C++. We’re feeling a bit apprehensive and scared of diving into something where we might waste a lot of time.

Now the idea I suggested is that we design the game engine and the models in C++ and the graphic engine can all be done in Python. In my mind, the graphic engine is simply showing characters moving, things being built, units attacking each other, while the game engine is doing all the nitty gritty calculations and passes these values to the graphic engine and the names of the units and buildings, to update the scene.

Are there examples and/or instructions on how to have python and C++ to interact. I’ve googled a bit, but I probably wasn’t googling the right thing, and there are no clear examples on the interaction between the two.

I’m not sure if this would have an affect but the C++ code is being compiled using MinGW. Thank you very much for the help.

Last I checked (around a month ago), Panda cannot be compiled with MinGW, unfortunately.

I am a newb so take everything i say with a pinch of salt, but I feel it will be much better to go for the pypi version of python. the numpy tools are great for number crunching and are quite fast.
this will ensure that you code remains in a single language.

the game i am working on also have heavy number crunching requirements and i think i will be using the multithreading and numpy features of pypi for them.

I’m not entirely sure why you’re embarking on a mixed-language project. Most people don’t add this trouble to themselves unless they have a good reason; usually, a good reason to use two different languages is to take advantage of the best features of both.

The best feature of Python is its ease of rapid development. The best feature of C++ is its fast execution time. So, people who code a project using Python + C++ usually use Python to do almost all of the development, and only use C++ to code those few parts that require particularly fast execution time.

That said, since Panda can be used with either C++ or Python, you can do a mixed-language game that uses Panda. There are many different ways to connect C++ and Python. In Panda, we use our own home-rolled tool called interrogate; you can use this too, but it’s not well documented and it’s a little tricky to set up. Or, you can use a third-party tool for this purpose such as SWIG or Boost.Python. Or you can write the interface layer yourself using low-level C/Python calls as described in the Python API.

It is true that you will need to compile your C++ code with MSVS 2008 in order to successfully call Panda3D. Unfortunately, we don’t support MinGW.


Thank you David for the response, that was what I was looking for. I agree we should be avoiding mixing two languages but we are very curious and want to try this out. Not only this we want to do most of the stuff in C++ which are the game engine and the models, but the graphics in Python. To avoid wasting time, we’ll play around with interrogate and the others you’ve mentioned and see if it’s what we want and expect. If not we will then do the whole project in Python. Thank you everyone for the input and enjoy your weekend.