Skip to main content
2 of 7
added 1 characters in body
Engineer
  • 30.4k
  • 4
  • 76
  • 124
  1. Read Evolve Your Hierarchy.
  2. Don't use umpteen methods to create different entities, this is not maintainable since configuration-specifics belong in external data files, not in code. So create one parameterisable method that supports construction of any type of entity -- and it's parameters come from external data files. Not createPlayer(), createEnemyOne(), createAsteroid(), but instead createEntity(PhysicsComponent, SpriteComponent, HealthComponent, WeaponComponent(s)) with those parameters collectively specifying a unique object such as an asteroid.
  3. Use the builder pattern specifically because you need a class dedicated to translating said configuration data into concrete entities, while maintaining separation of concerns between classes (e.g. your game class "Main" should not be constructing entities, but it should be delegating the task to another class).
Engineer
  • 30.4k
  • 4
  • 76
  • 124