Jump to content

  • Log In with Google      Sign In   
  • Create Account


Embedding Python into game engines.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
28 replies to this topic

#21 Andrew Nguyen   Members   -  Reputation: 150

Like
Likes
Like

Posted 21 January 2002 - 01:26 PM

That''s C->Python, now show me Python->C for GOD''S SAKE!

Sponsor:

#22 gmcbay   Members   -  Reputation: 130

Like
Likes
Like

Posted 21 January 2002 - 02:40 PM

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.




#23 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 21 January 2002 - 04: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.


#24 Andrew Nguyen   Members   -  Reputation: 150

Like
Likes
Like

Posted 21 January 2002 - 05:01 PM

Call Python from C, thats what I meant.

#25 mutex   Members   -  Reputation: 1109

Like
Likes
Like

Posted 21 January 2002 - 05:22 PM

? Calling Python methods from C is even easier.


PyObject* py; // irc connection object
PyObject* obj; // my existing python object, say an event handler
PyObject* res = PyObject_CallMethod(obj, "OnJoin", "Oss", py, sPrefix, sChans);
Py_XDECREF(res);



#26 Andrew Nguyen   Members   -  Reputation: 150

Like
Likes
Like

Posted 21 January 2002 - 05:32 PM

Finally, thank you, I now support the use of Python in engines.

#27 Siebharinn   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 03:31 AM

Whew, that''s a relief!! I was about to switch to something else.

#28 Andrew Nguyen   Members   -  Reputation: 150

Like
Likes
Like

Posted 22 January 2002 - 03:48 AM

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/)



#29 kvh   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 04:35 AM

Rodney? Is that you?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS