1

If embedding Pygame to C++ to have a game be an executable, is there any extra process I would have to use in order to use Pygame functions when embedding into C++? As opposed to just writing embedding code in C++ for normal Python code?

To clear cut the question I want to know if it's the same process without having to call different functions.

EDIT: My question is if I have to call different functions in C++ when embedding Python code that uses Pygame modules. I am NOT using pygame2exe nor py2exe. I never even mentioned those. My question is solely about code embedding.

0X1A
  • 143
  • 5
  • I don't understand what you're asking exactly. Are you wondering if you need to change Python function calls when using Pygame2exe? Please clarify your question. – Laurent Couvidou Oct 14 '12 at 21:08
  • Oh god that circularity... Anyway, I highly doubt this has anything to do with game development. If you're looking for a way to compile Python code, @LaurentCouvidou has your answer. – jcora Oct 14 '12 at 21:18
  • Why are you trying to embed Python with Pygame into C++? Just use SDL, since that's what Pygame is built on. Pygame is supposed to be the boss of the application. You can write C++ modules that are loaded from Python, but if you try to embed Python and scripts that depend on Pygame, you're gonna have a bad time. – michael.bartnett Oct 15 '12 at 01:29
  • I would like to see this question reopened and an answer from @michael.bartnett giving some details about the pitfalls of such an approach. If I wanted to use Python for 'scripting' inside of a game that's already mostly written in C++, would this not be the way to go? – tugs Oct 15 '12 at 19:47
  • @tugs I don't think I could add much more useful information than what's already out there: 0, 1, 2, 3 – michael.bartnett Oct 15 '12 at 23:04
  • More here: 4, 5, 6, 7 – michael.bartnett Oct 15 '12 at 23:04
  • And last two: 8, 9. You are embedding python, not pygame. Pygame is meant to be used as a library where the core of your game code, your window control, everything, is written in Python, with Pygame providing C-accelerated rendering and system event handling for input and such. This doesn't really warrant an answer. – michael.bartnett Oct 15 '12 at 23:05

1 Answers1

2

When you embed Python into C++, you just have to set up the code to call the Python functions in C++. The Python libraries that you use, such as Pygame, have no effect on the C++ binding code you need to use.

Kylotan
  • 24,329
  • 3
  • 51
  • 94