Python and the Game Engine

Hi fellow regular posters of this board.

I’m new to the Blender community and I hope I’ll stay here for a little while. I guess you’ll be quickly bored so here’s a fast introduction: I’m a student in a french engineering school and I’m working with other students on a virtual reality project which will be featured on the internationnal show/contest “Laval Virtual” which can lead us to the IVRC in Japan if we win (

K this does not really interest you. Enough chitchat.

During almost two weeks I’ve been collecting information about Blender because we’re going to use the Game Engine to power our project.

Thanks to the incredible tutorials here and there, we quickly learned the basics. However, I have a hard time finding tutorials about using the Game Engine with Python scripts. The only page we managed to find is
That’s very little information and we are looking for more stuff. I admit I’m a bit lost. Where do we program the game main loop ? How to move stuff with Python, and those other kind of basics. We don’t want to use the game logic panels and we do want to program everything with Python because the project will become really complex in the near future (interaction with a webcam, dynamic vertex translating, etc. etc)
So does anyone could give me some good links?

Sorry for the long post and thanks for reading that crap from a blender noob.
So far,

You don’t.

The python code you write to a controller makes calls to functions written in C.

Doesn’t the tutorial link you posted explain one way to move things through python?

Anyway, python scripts in blender are usually used to handle actuators and sensors that you will have to connect to your python controller. The events are basically generated the same way as they are with logic bricks, except with python you can control pretty much everything those actuators do, when they do it, and how.

I don’t know any links to more py tutorials in relation to the BGE, but I did write a script to handle Double Click detection just a while ago:

I made decent comments on the code, I think. So it may show you some basics.

GameLogic API reference(not sure it’s up to date but still very usefull):

well heres an up to date python documentation.

boots, you link isn’t working right.

Tony P,

You cannot make a game with Blender that is completely devoid of logic bricks. As Social already alluded to, the “main loop” is written in the C code of the BlenderPlayer, and it is not directly accessible. I recommend reading over the Game Engine Reference (it’s really old but it should help you with the basics about Python and logic interfaces). It says it in there, but I’ll say it for you here too.

print dir(<i>module name here</i>)

is your new best friend. It will print a list of available functions in the specified module to the console. Hook it up this way in the logic panel:

Always Sensor (Positive pulse mode off) >> Python Controller: script name

Using the Always sensor with postive pulse off makes it a “Once” sensor. Great for initializations.

Anyhow, hope that helped you along the way.

Tony D

hmm i dont know why it dont work…

try this

Thank you for replying.
I’m at work right now but I’ll check all that docs as soon as possible.:stuck_out_tongue: