Book Image

Learning Java by Building Android Games

By : John Horton
Book Image

Learning Java by Building Android Games

By: John Horton

Overview of this book

Table of Contents (17 chapters)
Learning Java by Building Android Games
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the Snake game activity


Not all of this code is new. In fact, we have either used most of it before or discussed it earlier in the chapter. However, I wanted to present every line to you in order and in context with at least a brief explanation, even when we have seen it before. Having said that, I haven't included the long list of imports as we will either be prompted to add them automatically or we can just press Alt + Enter when needed.

This way, we can remind ourselves how the whole thing comes together without any blanks in our understanding. As usual, I will summarize as we proceed through the implementation, and go into a few bits of extra depth at the end:

  1. Add an activity called GameActivity. Select a blank activity when asked.

  2. Make the activity full screen as we have done before.

  3. As usual, create some sound effects or use mine. Create an assets directory in the main directory in the usual way. Copy and paste the sound files (sample1.ogg, sample2.ogg, sample3.ogg, and sample4...