6.8.5. Method newGame

Method newGame (Fig. 6.11) resets the instance variables that are used to control the game. If variable gameOver is true, which occurs only after the first game completes, line 203 resets gameOver and lines 204–205 create a new CannonThread and start it to begin the game loop that controls the game. You’ll learn more about this in Section 6.8.14.

180      // reset all the screen elements and start a new game181      public void newGame()182      {183         // set every element of hitStates to false--restores target pieces184         for (int i = 0; i < TARGET_PIECES; i++)185            hitStates[i] = false;186 187         targetPiecesHit = 0; // no target pieces have been hit188         blockerVelocity ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.