OOP in the BGE

Discuss Blender Game Engine

OOP in the BGE

Postby dieweisebanane » Tue Mar 09, 2010 10:48 am

Hi Community,

Today I found something really interesting about the OOP in the BGE in this thread:
http://www.blendpolis.de/viewtopic.php? ... op#p329403
Perhaps you can't read german and even though you could it's really hard to understand (anyway for me after reading and reading again...).
So I try to summarise:

1. Complex python-structures in blender are only possible with the "Python Module Controller".

2. Because you can't access the KX_GameObject by inheritance you could make your own class "GameObject" and give this constructor the controller of the KX_GameObject.
Than you can instantiate it wherever you want in your code and make the instance of your "GameObject" as Property of your KX_GameObject.

For a concrete example he uploaded a file in this thread:
There his GameObject inherit from an other class that allows to save the object states.
The mainfunction works only for linux because of the paths he used but the structure shows hopefully what he meaned.

Well, why I wrote this to you?
Because I think it's a style that should see the whole blender community, particularly the beginners because this reduces a lot of work quite from the beginning of a project.
Like in my case; Now I would like to rewrite all my BGE-code because this architecture is much cleaner.

With kind regards,
dwb
visit my website www.dieweisebanane.de
User avatar
dieweisebanane
 
Posts: 13
Joined: Fri Jan 29, 2010 11:25 am
Location: Germany

Re: OOP in the BGE

Postby Infinitewave » Tue Mar 09, 2010 10:56 am

Wow. All I heard was a rush of wind (the sound of that going waaay over my head!) I'm sure at some point in the future I will be able to appreciate it much more, however. Like when I understand at least half of it :) Thanks for posting it :~)
Infinitewave
 
Posts: 35
Joined: Wed Jan 27, 2010 3:16 pm

Re: OOP in the BGE

Postby irakrakow » Tue Mar 09, 2010 11:28 am

Based on my limited knowledge of German and your explanation, the approach does sound promising. There is a bit of a learning curve for most Blender users, both in Python and object oriented programming. I'm going to cover both of these in my Python 3 tutorials. A clean class hierarchy will definitely help to make programming in the game engine much easier.

Thanks for posting this.

Ira
User avatar
irakrakow
Site Admin
 
Posts: 438
Joined: Fri Jan 22, 2010 9:01 pm


Return to Blender Game Engine

Who is online

Users browsing this forum: No registered users and 1 guest