🐍Snake: an exercise in game development
7 days plan for creating a Snake game
Last updated
7 days plan for creating a Snake game
Last updated
I was inspired by GMTK's video "How I learned Unity without following tutorials". His idea was to learn the very basics of Unity game engine (things like game objects, components, transforms, scene editor controls) and then create several simple game clones and learn the rest "on demand", when it's needed in the game. This resonated with me, so I decided to go with Snake which I liked a lot as a kid. I came up with a plan for 7 days to keep me focused and produce a finished game that I can publish it on itch.io and send it to friends or strangers to play.
I've managed to stick to my plan, see my published game on itch.io and source code on GitHub. Some of those seven "days" were short (1-2 hours of work), some were longer (5-6 hours), but overall the planning was good, the process was fun, so I decided to share it along with some Unity/C# knowledge I've learnt (something for next posts).
I think it may be also useful for people who want a large but structured exercise in game development.
Before implementing a game clone, I think it's very important to understand in advance what you want to implement: which features/power-ups of the original game to support. This will limit your scope and make possible to actually finish the project. It is also useful to set some time limits for things like game sprites or sounds: one may spend ages tinkering with the visuals and never attain perfection! As someone in the Internet said: "Your first game will be ugly", so there is no need to focus on that too much.
Also, before coming up with a plan I went to itch.io and looked at existing Snake implementations to get ideas and remind myself of the gameplay, see how people display scores, endgame screens and other stuff.
I ended up with this "design document":
Create a clone of a basic Snake game, with a snake, apples, and walls on a rectangular 2D grid. The player can press arrow keys to move the snake. Speed of the snake should gradually increase. The game should keep the score: number of eaten apples. It should also keep high-score (fine to keep it in memory).
There should be different sprites for snake head and snake body, they should be properly oriented.
There should be basic 2-frame animations on some sprites (snake head, apples).
There should be background music, plus sounds for eating an apple and hitting the wall. It can be sourced from free game assets.
There should be title game screen with some nice picture, the main "level" where gameplay is happening, and the end game screen displaying the score and high score when snake dies.
It's not a proper Game Design Document of course, just a list of points that must be implemented to consider the game done. To get a feel of a real GDD, you can look at this template from a course in University of North Carolina.
When working on the items from the list below, I kept a dev log, adding short notes about difficulties I had, resources used, things learnt, and rough amount of time I spent. It was useful and allows me to resurrect those experiences now.
I also used version control system and committed the state of the project at the end of each day.
My version at the end of Day 1:
My first version of Simple GameOver screen:
As you may have noticed, there is almost nothing Unity-specific in this plan, so it can be easily applied to learning any other game engine. Admittedly Snake is a very simple game, so if you just want to make Snake (and not to learn Unity), then it may even make sense to code it in a simpler 2D engine.
So give it a go, try to follow the plan or adjust it to your taste and see where it takes you! Please feel free to send links to your published games to my email: "veselov" at google mail, I'll be happy to see them.
In the next posts I plan to cover how I fared with that plan, reflecting on my dev log and sharing insights, so you can come back later and compare our experiences.
If you are really new to Unity and want to learn those basics I mentioned in the very beginning, I found those resources helpful:
Brackey's playlist "How to make a game in Unity" - 10 short videos (each about 10 minutes), fast paced, well explained and to the point. It covers the basics: game objects, components, transforms, C# scripting and using the Scene editor. And at the end you have quite a fun 3D (!) game!
For people with some experience with programming, I found Unity documentation quite good: you can start from "Game Object" section in Unity Manual. Another good reference is "Important classes" page which explains the classes you will see used in Unity code all the time. There are also simpler official Unity tutorials, ava
CatLikeCoding tutorials are text-based and usually quite in-depth. This one explains how game objects and scripts work in Unity, creating a 3D clock in Unity as an example.