Here is an outline of the topics we will cover and your tasks for this chapter:
- Learn the trouble with using a factory for game objects
- Implement the Prototype pattern
- Learn how the Mach5 engine uses the Prototype pattern
- Implement components within the Mach5 Engine
- Learn how to define objects completely in a file
In Chapter 5, Decoupling Code via the Factory Method Pattern we learned how to use a Dynamic Factory to decouple our stages, components, and objects from higher level modules. We did this by placing the dependencies of each derived class into a separate builder class instead of a high-level module. Let's look at an example of creating a derived type stage builder:
//SplashStageBuilder.h-------------------- #include "M5StageBuilder.h" class SplashStageBuilder: public M5StageBuilder { public: virtual M5Stage* Build(void); }; //SplashStageBuilder.cpp-------------------- #include "SplashStageBuilder.h" #include...