Embedding Python into game engines.
That''s C->Python, now show me Python->C for GOD''S SAKE!
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
1) Its very easy to call Python from C/C++ and vice versa. Python has been designed to allow for ease-of-embedding for a long time now.
2) Crystal Space game engine has a Python scripting component, as does the Nebula Device game engine.
3) Disney''s new MMORPG ToonTown uses Python for scripting.
4) Ultima Online II was using Python as its scripting language, though the entire project has since been canned.
5) Blade of Darkness did scripting in Python
6) I''m sure there are more gaming projects, including pro projects, which use Python, but I don''t know them off hand.
7) Nobody is going to write low-level graphics routines in Python, or any other scripting language for that matter. It would be used to do game-logic, AI, that sort of thing. It can easily be made to have access to graphic objects (meshes, etc) at a high-level, move them, rotate them, etc, via calling methods, but all the heavy-lifting would be done underneath the full engine in C/C++ if you''re sane. Python is plenty fast for this type of higher-level scripting.
8) Given #7, if you don''t see how Python could be used to control graphics without having the low level graphics code itself written in Python (this means you Andrew), please stick to the beginners boards only.
9) Andrew Nguyen is an idiot. Is there any way to killfile people on this message board? If not, could it be added? I don''t fault people for ignorance, we are all ignorant on every subject until we take the time to learn it; but to be ignorant and annoying and to think you know what you''re talking about when you don''t just makes you look like a complete tool.
2) Crystal Space game engine has a Python scripting component, as does the Nebula Device game engine.
3) Disney''s new MMORPG ToonTown uses Python for scripting.
4) Ultima Online II was using Python as its scripting language, though the entire project has since been canned.
5) Blade of Darkness did scripting in Python
6) I''m sure there are more gaming projects, including pro projects, which use Python, but I don''t know them off hand.
7) Nobody is going to write low-level graphics routines in Python, or any other scripting language for that matter. It would be used to do game-logic, AI, that sort of thing. It can easily be made to have access to graphic objects (meshes, etc) at a high-level, move them, rotate them, etc, via calling methods, but all the heavy-lifting would be done underneath the full engine in C/C++ if you''re sane. Python is plenty fast for this type of higher-level scripting.
8) Given #7, if you don''t see how Python could be used to control graphics without having the low level graphics code itself written in Python (this means you Andrew), please stick to the beginners boards only.
9) Andrew Nguyen is an idiot. Is there any way to killfile people on this message board? If not, could it be added? I don''t fault people for ignorance, we are all ignorant on every subject until we take the time to learn it; but to be ignorant and annoying and to think you know what you''re talking about when you don''t just makes you look like a complete tool.
January 21, 2002 10:38 PM
quote: Original post by Andrew Nguyen
That''s C->Python, now show me Python->C for GOD''S SAKE!
Why don''t you try reading other people''s posts before posting again? Someone has already posted an example of Python calling C above:
quote:
Wrong again. You call the C functions simply by importing the extension module. For example, say I made a Python module called GSDK to provide access to the graphics engine SDK from Python. To use it in Python, I''d simply do the following:
import GSDK
GSDK.InitGraphics()
GSDK.DrawText("This is NOT hard!"
GSDK.UpdateScreen()
GSDK.Wait(10000)
GSDK.TermGraphics()
Now shut up with your Python->C whining already.
Call Python from C, thats what I meant.
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
? Calling Python methods from C is even easier.
PyObject* py; // irc connection objectPyObject* obj; // my existing python object, say an event handlerPyObject* res = PyObject_CallMethod(obj, "OnJoin", "Oss", py, sPrefix, sChans);Py_XDECREF(res);
Finally, thank you, I now support the use of Python in engines.
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
According to Guido, from a question by me:
> Hello Guido, how exactly do I call Python functions from C/C++?
One way is to pass a Python expression or statement to one of the
functions documented here:
http://www.python.org/doc/current/api/veryhigh.html
Note that you can''t in general get a result back with these APIs.
You can also use the PyObject_Call* functions from this page:
http://www.python.org/doc/current/api/object.html
--Guido van Rossum (home page: http://www.python.org/~guido/)
> Hello Guido, how exactly do I call Python functions from C/C++?
One way is to pass a Python expression or statement to one of the
functions documented here:
http://www.python.org/doc/current/api/veryhigh.html
Note that you can''t in general get a result back with these APIs.
You can also use the PyObject_Call* functions from this page:
http://www.python.org/doc/current/api/object.html
--Guido van Rossum (home page: http://www.python.org/~guido/)
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement