Using builders with objects

Our game objects are mostly just collections of components. Each object type will have different components and component data based on the decisions of the designer. As the development progresses, those collections are likely to change. Remember, even though each individual component has a builder in the factory, the object will need to somehow instantiate the separate components. Let's look at shortened examples of using builders for the Player and Raider objects:

//PlayerBuilder.h-------------------- #include "M5ObjectBuilder.h"  class PlayerBuilder: public M5ObjectBuilder { public: virtual M5Object* Build(void); };  //PlayerBuilder.cpp-------------------- #include "PlayerBuilder.h" #include "M5Object.h" 

Get Game Development Patterns and Best Practices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.