The code structure

We will have two activities, one for the menu screen and one for the game screen. The menu screen activity will be called MainActivity, and the game screen activity will be called GameActivity. You can find all the completed code files as well as all the assets such as images, sprite sheets, and sound files in the Chapter8/Snake folder in the download bundle.

MainActivity

In contrast to our other projects, the menu screen will not have a UI designed in the Android Studio UI designer. It will consist of an animated snake head, a title, and a high score. The player will proceed to GameActivity by tapping anywhere on the screen. As we need to accomplish animations and user interactions, even the home screen will have a thread, a ...

Get Android Game Programming: A Developer’s Guide 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.