Me and a team of junior developers are making a role playing game. We would like to make something similar to https://bunk.town/ I have only made a Tetris clone which doesn't require much knowledge about game architecture; however, this game will. Is an ECS architecture a good fit for this kind of game? If so how should i go about implementing it in python?
I know that one of the major drawbacks when making an ECS with python is the inability to utilize the cache. There is the advantage of being able to compose entities easily and archetypes may help iteration speeds.
I'm working with people relatively new to game programming. They lack experience and im not sure if i should make something like an ecs yet.
I tried putting something together but I'm partly unsatisfied with how it turned out. Its not finished, but i can loop over a specific group of components in an archetype. Id appreciate any guidance as Ive struggled with this in the past. Here is the source code.
class Component:
pass
class Archetable:
def __init__(self):
self.entities = []
self.type = set()
def __iter__(self):
for entity in self.entities:
yield entity
def over_components(self, *Components):
for components in self.entities:
entity = []
for component in components:
if type(component) not in Components:
continue
index = Components.index(type(component))
entity.insert(index, component)
yield entity
class Camera(Component):
def __init__(self):
self.id = 0
class Controller(Component):
def __str__(self):
return self.__class__.__name__
arche = Archetable()
arche.entities.append([Controller()])
arche.entities.append([Controller()])
arche.type.add(Controller)
arche.type.add(Camera)
for controller, in arche.over_components(Controller):
print(controller)