OOP in the Blender Game Engine?

Hi I posted a question yesterday about OOP in Blender and it looks like I won’t need it, but if I do need, how would I integrate an OOP system into the blender game engine? Like for an rpg make a class called actor, items, and make objects of them and somehow relate these objects to in-game objects like meshes with properties or something

I have a video tutorial in which I take the OOP approach to implement basic AI: http://www.youtube.com/watch?v=12-zTKR4tW8#t=2m2s

I think it covers what you’re interested in, at least partially.

ok thanks i’ll check your tutorials out

What do you think is OOP system?

My perspective: The BGE’s logic is focused on objects = object orientated.

This is up to you and what design you choose. As this is a very general description, there are really much possible designs.

Here are some ideas:

Use MVC architecture (model view controller):
You build your game model in Python without any relation to the BGE.
The view presents the model to the user via BGE.
The controller receipts input from the user via BGE and interacts with the model.

This design allows to replace the controller and view with something else (e.g. Another game engine, another input, text output).
The relation to in-game objects is to controller and view (not to the model directly)
Example: a chess engine does not need any relation to the BGE. But the status of the playground is presesnted by the viewer and the input of the player is processed by the controller. The same chess engine would work if the interaction would be processed

  • via network communication (with a remote controller and a remote view)
  • via text (with a text controller and a text view)
  • via email (with an email controller and an email view)
    They could even exist at the same time

You can use the MVC architecture that integrate game object to the model. But this creates strong dependencies to the BGE. This might be wanted, may be not.

If you look for a very integrated approach, you can create refer to python objects by storing object references in properties. As game objects have a Python binding too, you can store References to game objects in properties too.
Indeed you can do the other way around by storing references to game objects at any container that exepts objects.

To get more understanding of the BGE I suggest you read the BGE guides that you can find in my signatures.

Ok thanks :slight_smile: