More on collisions

You might have found while playing our little game that you can make the snake turn back on itself or it even goes through itself. Anyone who remembers the original will know that this results in an immediate game over!

What we are going to look at now can essentially be split into two parts. First, we will fix the snake's ability to slither back on itself, as seen in the following screenshot:

More on collisions

Second, we will look at stopping the game when the snake collides with another part of its body, as seen in the following screenshot:

More on collisions

Stopping ...

Get LibGDX Game Development By Example 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.