How do I communicate with an IronPython component in a C#/XNA game?

Posted by Jonathan Hobbs on Game Development See other posts from Game Development or by Jonathan Hobbs
Published on 2012-04-10T11:28:55Z Indexed on 2012/04/10 11:44 UTC
Read the original article Hit count: 226

Filed under:
|
|
|
|

My XNA game is component-oriented, and has various components for position, physics representation, rendering, etc, all of which extend a base Component class. The player and enemies also have controllers which are currently defined in C#. I'd like to turn them into Python scripts, but I'm not sure how to interact with those scripts.

The examples in Embedding IronPython in a C# Application suggest I'd have to create a wrapper class (e.g. a Script component) which compiles a Python script, and call the Update methods of the component in the script

Is this the most effective way of working with a Python object?

I feel that I'm missing something in my research - there must be a way to load up a script, instantiate a Python object and then work directly with it from within C#. Or is the wrapper required?

© Game Development or respective owner

Related posts about XNA

Related posts about c#