Now we are well versed on how the Observer pattern works and we have had a good look at the interfaces we will need to write and how they will be used we can put all the theory into action in the Scrolling Shooter project.
As the specific use for our broadcaster and observers is to handle the player's input we will code a class to handle the screen touches for the HUD. As a reminder, the GameEngine
class will be a Broadcaster and two separate classes that handle user input will be Observers. As the HUD and the player's spaceship are very different things it makes sense for each of them to handle their own input.
We will code the UIController
class which will be our first Observer (for the HUD play/pause button) in this section and later in the project we will code our second Observer to handle the spaceship controls.