Note: I have completely rewritten and improved this game. Most of my traffic comes from these posts, so I've not deleted them. Please use the new version which can be found here.
Snake is a classic game in which the player controls a snake that moves around and eats fruit. With each piece of fruit that the snake eats, it grows in length by one, and the player earns one point. The player loses the game when the snake either collides with it's tail, or a wall.
This tutorial series will cover the creation of the snake game from start to finish, and will provide full source code at the end. The tutorial will be broken up into several parts, each covering a different section of the game before putting it all together and supplying the source code at the end.
- Part 1: Introduction
- Gives an overview of the game and the tutorial series.
- Protip: You're reading it.
- Part 2: The Game Engine
- Covers the game engine.
- Part 3: Game Board
- Covers the GameBoard class.
- Part 4: The Snake
- Covers the Snake class.
- Part 5: Controller Input
- Covers the input system.
- Part 6: Fruit and Scoring
- Covers spawning and consuming fruit.
- Covers the points system.
- Covers how the snake grows in size.
- Part 7: Putting it All Together
- Goes over a few finishing touches.
- Shows the finished product.
- Contains the complete source code.