Coding the other interfaces
There are three more interfaces that we need to code. They are for communications between specific classes of the game. We need the GameState
class to be able to trigger a new level via the GameEngine
class and we will code the EngineController
interface for that.
We will need the GameEngine
class to broadcast to multiple input related classes whenever the player interacts with the screen and we will need these input-related classes to register themselves as observers just as we did in the previous project. For this we will code the GameEngineBroadcaster
interface and the InputObserver
interface.
Let's quickly add them now.
EngineController
Add the EngineController
interface as shown next.
interface EngineController { // This allows the GameState class to start a new level void startNewLevel(); }
In the next chapter we will make GameEngine
implement this interface as well as pass a reference to GameState
. GameState
will then be able to call the startNewLevel...