Easy UI with commands in Mach5

Now that we have seen what the Command pattern is, let's look at how it is used in the Mach5 Engine. You will be surprised that there isn't much code here. That is because using the Command pattern is easy once you understand the code behind it. In this section, we will look at both the component responsible for the mouse click and the commands that are used within the engine.

Let's have a look at the M5Command class:

class M5Command { public:   virtual ~M5Command(void) {}//Empty Virtual Destructor   virtual void Execute(void) = 0;   virtual M5Command* Clone(void) const = 0; }; 

Here is the M5Command class used in the Mach5 Engine. As you can see, it looks almost identical to the Command class we used in the example. ...

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.