Classes and logic...my human logic error! Tips anyone?

i’m approaching a soccer game in blender the oop way so i’m currently faced with the difficulty of how to initialize these objects

So here are my classes
1)Player:
This class is constructed by a mesh object and a text plane and ofcourse the players name. Now i’m looking for a way of creating many instances with player meshes as cubes.
The firs approach i took was to create an external file containing all the names for my instances and use a loop to instantiate my players but my constraint comes now to how to create those cube objects to go along with eac instance and i’ll need to create varying attributes for each player in the near future.

2)Team:
This class instances itself by searching for players with a specific team name and appending it to its ‘TeamPlayerList’ and when a match begins the players are put on the field according to the teams formation

Any tips and maybe even class suggestion to handle specific functionalities.?

this silence either means my question was to difficult or no one is willing to type long answers

Yes, your question is not easy to understand for a non-programmer.

I suggest you go a bit more hi-level when defining your requirements. The usage of classes is part of a specific implementation. This does not necessarily mean it is the best or easiest way.

With blender you can have an object-orientated design without ever creating a class ;). Because blender already uses objects.

Let me split down your requests as far as I understand.

You want to have visible objects that represent players.
Players should have the attribute “name”. I guess you want them visible somehow.

You want to store the player names somewhere. External file = saveLoad. I suggest to deal with that separately by an separate object. I’m sure you want to save/load more than just names.

You want the players/player representations created on the fly depended on the content of the storage (list/dict whatever).
I suggest to encapsulate this into an object “PlayerManager”. It can deal with the adding/removing of objects. More specifically creating player objects from stored content and removing player objects from scene.

To add players I suggest to look at groups and group linking. You can find a manual at my signature/guides. This makes it easy to keep the objects independent from each other.

The team is similar. I think you need a team manager. Define what it should do. Then you can think about how to do that.

BTW: you can use classes as internal model. But you need Python to access them. Properties might be a good alternative.

I hope this sounds not to confusing.

its perfect monster just what i needed to hear, though, I heard about this KX_GameObject you can inherit from when creating classes, which in my thoughts give your class abstraction all the attributes and functions of the owner object but i heard someone say you can’t inherit it the classical way:

“class Player(KX_GameObject):”

You can inherit in such a way. However, naturally any reference to the gameobject is broken, so you’ll need to take it back from the controller.owner or scene.objects[‘object name’]

Ok now lets say i want to instance about 100 player objects all with different attribute values (in the field, not all player are on the same level in terms of running, ball control, passing, accuracy e.t.c) it would take days for me to do this manually so what i need is some kind of encoding scheme/standard to do this maybe through a loop. Please do tell if you have a glimpse of what i’m saying but think i need to rephrase it to be a bit more clearer

Its all clear thanks monster. About the composition of a player, I had already enlightened my self about the different components that make up the player like you said, But i have to let you know that i’m not really repeating the same logic what i want is to instance whatever player with all the components that make up the player. But i’ll just read through your Guides to see what else can I find. Thanks for enlightning me about an alternative.

This may be somewhat premature, but the Hive system fully supports what you ask for: the instancing of objects that consist of several components, both visual and logic, organized in classes. These classes can be created the usual way, in Python, and/or visually, using the components as nodes.

It will take many months before the Hive system will be fully usable within the BGE (it is one of this year’s GSoC projects), but there is already a working Panda3D demo.