Game uploadedDownload Otherworlder here
Let me know here if you encounter any bugs. Thanks!
(log in to comment)
The Component class is defined in a module I made called enco. It is documented, but to be honest, the basic idea is hard to get used to. If you do try it, let me know if you have any feedback!
class A(object): def __call__(self,cls): def wrapper(*args,**kwargs): print('class decorator is called :)') return cls(*args,**kwargs) return wrapper @A() class B(object): pass b = B()
I think this style is quite fun, because use class modifies another class is easy to accept by noob like me, not instance modifies another class. In my eyes, this is normal, say the code maybe like
class C(object): @classmethod def __init__(self,cls): print('class decorator runing') return cls() @C class D(object): passa class modifies a class and return the class, Of course this will raise an error :)because decorator is that its return value must be callable. So I have to write the `__call__` method, How about
class E(object): @staticmethod def __call__(cls): def wrapper(*args,**kwargs): print('class decorator comming') return cls(*args,**kwargs) return wrapper @E class F(object): passI just use @staticmethod to treat the method as common function, again,it would not work, maybe just for fun :) As the examples shows in enco-test.py, there are really many confusing things. I need a pen and a paper to clarify the results, hard to say use it.
I think I need more practicing time, to be honest, ECS is really hard to me, say, I use kivy, there is a game engine called kivent based on kivy, but I can not use it, because it is using ECS. I even can not blit a image on screen, because it is using system! I think when I have a month free time, I would research it. Anyway, thank you for teaching me this, maybe several years later, I would get your idea of this ECS implementation. :)
I also think I should not have called it enco. The basic idea is something I came up with while learning the benefits of an entity-component system, so I called it that, but it's really not the same thing as an ECS.
Between these two concepts - decorators and ECS - I think I understand why this module has not caught on. But thanks for checking it out!
In my eyes, I think enco is fine, it is not hard to understand, just entity's component, creating every components for the entity, then use think method if it need update. This is somehow quite like sprite in pygame. this concept and usage is more easier than typical ECS's components. It is still object oriented programming.
I am shocked when I found you created such repo in github 3 years ago :) Only from the time and experience, I think you must be right in using decorators here. :)
xmzhang1 on 2018/04/25 22:32:aha, awesome as always:) There is no bugs for me on Windows 10, python 3.6. My level is stop at red world 'race to win'. It is really hard to win in my eyes :) I am quite curious about the usage of `Component class`, itseemed use it as decorator. I really can not understand the usage here, it makes me confused :) Is there any tutorial about such usage? Would you kind to tell me the trick here?