Implementing the rules
Now, we should pause and think about what we need to do later in the project because it will affect what we do while implementing our rules. When the player's ship is destroyed or when player reaches their goal, the game will end. This implies that the game will need to be restarted. We don't want to quit back to the home screen each time, so we need a way to restart the game from within the TDView class.
To facilitate this, we are going to implement a startGame method in our TDView class. The constructor will be able to call it and our game loop will also be able to call it when necessary as well.
It will also be necessary to pass some of the tasks that the constructor currently performs onto the new startGame method so that ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access