How do you approach OOD with GameObject and Components?
I’m trying to better understand things in a deeper sense. I usually have something like:
class Player(KX_GameObject)
and then I have several
class Movement(KX_PythonComponent)
class UI(KX_PythonComponent)
class Animations(KX_PythonComponent)
Is this a sound way of doing it? I feel like I’ve been learning a ton about OOD, OOA, OOP and I’m struggling to implement it in my code using Components and GameObjects and Properties inside of UPBGE.
I want to better understand the relationship between a GameObject and a PythonComponent. When I create a Cube and create a KX_GameObject with it and also a KX_PythonComponent. I notice that the KX_GameObject has access to the Component class through a self.components
list. Giving you access to all the attributes and methods inside your Component Classes associated with that same object in your scene.
I also just realized that in the Game Object there is no self.object
like in the Component Classes. But in KX_GameObject self
is the object. And something cool is all the methods I create inside of my KX_GameObject class are passed down to my Component classes like Inheritance.
I want to design a game using sound design and OO principles. Does anyone have any experience with this especially using the classes that are special and not exactly "classes" like in any other python program. (I mean Player(KX_GameObject) and Movement(KX_PythonComponent) both don't have an init() method but they have a start() that act's like an init(), they also have to have a update() method that is called every frame.
Aucun commentaire:
Enregistrer un commentaire