This chapter is all about separating the user interface and input from the actions they perform. We will learn about the Command pattern and how it can help us decouple our code. We will do this by first understanding the problem then looking at how this could be solved in a C style fashion. Then after looking at the Command pattern in depth, we will see how it is implemented in the Mach5 Engine.
The following lists the things to be accomplished in this chapter:
- Learn the naive approach to handling input and why it should be avoided
- Implement the Command pattern using function pointers and the class method pointer
- Learn how the Mach5 Engine uses the Command pattern
- Implement UI buttons within the Mach5 Engine