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

Game design


If you haven't played the excellent Snake game before, here is an explanation of how it works. You control a very small snake. In our version, there is just a head, one body segment, and a tail. Here is a screenshot of our snake, made out of three segments:

The following screenshot shows the three segments individually:

Now, here is the thing; our snake is very hungry and also a very quick grower. Every time he eats an apple, he grows a body segment. This is a screenshot of the apple:

Life is great! Our snake just eats and grows! The problem that the player of our game needs to solve is that the snake is a little hyperactive. It never stops moving! What exacerbates this problem is that if the snake touches the side of the screen, it dies.

At first, this doesn't seem like too much of a problem, but as he grows longer and longer, he can't just keep going around in circles because he will bump inevitably into himself. This would again result in his demise:

For each apple eaten, we add...