Implementing the Component Object Model

Now that we have seen a basic version in code as well as a diagram, let's look at exactly how the Mach5 Engine implements this system. As you will see, the M5object, as it is called, contains a position, rotation, scale, and velocity. Of course, these elements could be contained in a transform component; however, these are so common that most other components will need access to this information. This is different to data such as texture coordinates or a circle collider's radius, which might not need to be shared at all:

//Component based Game object used in the Mach 5 Engine class M5Object {   public:     M5Object(M5ArcheTypes type);     ~M5Object(void);      //Public interface     void     Update(float dt);  void ...

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.