How to Make a Simple 2D Game
Author: Shiguang
Reviewed by: Yuandao
Preface
This article records some of my thinking and development work while I was building a simple 2D side-scrolling platformer for an assessment at my university’s studio (yes, really). If game development interests you and you would like to become a developer, it may offer some useful pointers. If you already develop games, you are welcome to get in touch and compare notes 😄!
Choosing an engine
When you decide to make a game, the first consideration is the game engine. In other words: which engine should I use? Two mainstream choices are Unity and Unreal Engine 4 (UE4), each with its own strengths and weaknesses. Unity’s 3D rendering, for example, is not as strong as UE4’s, but Unity offers many plug-ins that can make development more efficient.

Because this article concerns a 2D game, I think Unity is the better choice. (The real reason is that my university studio required it for the assessment.) When you hear “Unity,” however, you may think first of a hit electronic track by TheFatRat rather than a game engine. Here are a few games made with Unity to make the name feel less unfamiliar.
Many excellent 2D games were developed in Unity, including DEEMO, Plague Inc., Hollow Knight, Gris, Ori and the Will of the Wisps, and Lobotomy Corporation. Unity also suits relatively lightweight 3D games such as Monument Valley, The Room, Outer Wilds, The Almost Gone, and Kerbal Space Program.
(Every game just mentioned is great fun XD! Give them a try if any catch your interest.)
(Arknights was also made with Unity! An attempt to recruit another believer.)

Once you have chosen an engine, what comes next? Download Unity from its official website, of course (obviously)! Unity is completely free to download and install. I recommend choosing “Download through Hub” (the green option in Figure 4). Unity Hub makes it easy to manage projects and licenses. If a project refuses to open, an expired license may be the reason; reactivate it manually. The Hub also lets you install several versions of Unity and switch among them. Bear in mind that some features from newer editor versions may not work in older ones.

After installing Unity, you will need another important program: Visual Studio (VS). VS is where you write the code, since a game’s features have to be implemented through scripts. Unity scripts can be written in C# or JS; I recommend C# for reasons explained below. Anyone with some experience in Java can pick up C# fairly quickly because the two languages have similar syntax.
That completes the engine choice and basic setup. We can move on to development.
Development process
A side-scrolling platformer needs two basic elements: a map system and a character-control system. From there, we can ask what else to add. The game might have a story and tense combat; the answer depends on what kind of game you want to make.
My broad plan was this: after speaking with several NPCs, the protagonist would buy a weapon from a shop and use it to defeat the game’s final boss. (You may fairly complain that I have no imagination. What kind of plot is that…?) This plan called for dialogue, shop, item, and combat systems. Once the design established which features we needed, we could start writing code.
There are many ways to implement a feature, but we should try to choose the best one. Object-oriented programming is therefore important in game development. Items that fit into inventory slots, for example, share methods such as retrieving a name or a description of their use. We can define these common methods in an IItem interface. Use interfaces where practical and choose appropriate design patterns.
Next, you need an artist’s help. If you cannot draw, Unity’s Asset Store has many free resources. Still, it pays to stay on good terms with the talented artists around you. (Collapses.)

Technical difficulties
Technical trouble is normal when writing code; there is a reason people say ten minutes of coding means two hours of debugging. What can you do when a script defeats you and no one is available to ask? Baidu can help, but it carries too many ads, and some methods I tested were poor. When I searched for a character-movement script, several examples had serious problems.
More importantly, most examples you find while searching online are written in C#. That is why I recommended C# rather than JS as the scripting language above.
Here is a better website to try, though you can also search Google directly:
- Stack Overflow: https://stackoverflow.com/
You can also look for answers on YouTube. A few good game-development channels are:
Brackeys (covers a very wide range of topics)
Blackthornprod (less material than the channel above, but all of it is practical)
Code Monkey (plenty of material on C# programming)
Telegram has a fairly active Unity technical discussion group where you can ask any question. English only. Telegram link: t.me/unityThreeD

For readers who cannot access sites outside mainland China:
Bilibili — M_Studio:
https://space.bilibili.com/370283072?from=search&seid=10106931170352874846
Siki Academy:
Official Unity Manual:
Official Unity scripting documentation:
Chinese: https://docs.unity3d.com/cn/2018.4/ScriptReference/index.html
UnityList (many open-source projects):
Official C# documentation:
https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/


