Before we start writing code, we need to have a clear vision of what we are going to build. Let's first decide on what features the game will have and how it will look like so that we can make a plan of action.
We are going to build a classic snake game that you can see on the screen. When the snake eats food, it becomes longer, and the score increases. If the snake heats the wall or bites the tail game is over. Additionally, we will allow the player to stop the game by pressing the space button. To keep the user motivated, we will save the best score and show it alongside the current one. We make sure that the game looks good on any screen size, be it a tiny mobile phone or a large TV.
The main thing that we will export from Rust is Game struct with a constructor and two public methods. The first method will receive a duration from the last update and direction that the user wants a snake to take. The second method will check if the game is over.
All the source code you can find in the repository. Each part will have a link to the corresponding commit. There are a lot of things to cover in this short course, so let's jump in.