- Learning Java by Building Android Games
- John Horton
- 136字
- 2021-07-23 19:02:28
Final tasks
We only have a few more methods to complete and we have already coded the trickiest bits. The takeShot
method having just been passed the player's shot coordinates will compare them to the position of the Sub' and either call draw
or boom
depending on whether the sub' was hit. We will see how we translate the floating-point coordinates retrieved in onTouchEvent
to a position on the grid.
After that, we will code the super-simple boom
method which is just a case of increasing the font size, drawing a different color background and then waiting for the player to start another game.
The final bit of coding will be to draw the player's shot on the grid. He can then analyze the last shot compared to the distance and guess at his next shot.