O'Reilly logo

Android Game Programming by Example by John Horton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required