How to code a game: a beginner's guide to getting started

iD Tech in action

Take whatever preconceived ideas you’ve formed about coding and throw them out the window. 

Sure, there is a lot of what is witnessed in movies and on TV, whether that’s the scripting and many characters you see filling a computer screen, or the intent staring and tinkering of the person sitting in front of that screen.

But, my point is, coding isn’t an activity devoid of creativity. There is a lot of fun, imagination, and awesome that goes into (and comes out of) coding as well. 

Because think about it—all a programming language really is, is a way to communicate instructions to a computer. From there, once that code is transmitted, the output is magical, powerful, and obviously, oh so valuable.

One of the best ways to bring coding to life is through something like games, where a language like JavaScript, for example, can take your child’s zany world and cool character ideas and bring them to life. 

Said simply, code forms the building blocks of any game. Code is what breathes life into a game. It's what makes characters move and enemies attack. 

You might be able to create the skeleton of a game with models and game objects, but without code there is no movement, interaction, or game management.

Getting started

Perhaps the most difficult part about getting started coding a game comes when deciding what your young coder actually wants to create! A console game? Mobile app? Web app? And, in what language?

It’s a lot to take in, so here are a few comments to get the ball rolling. 

Through the journey, don't forget—someone learning to be a carpenter doesn’t go out and build an entire house as their first project. Instead, they might make a chair, or practice specific tools and cuts, and then move on from there. 

Kids will need to start small, but with time and practice, they can learn to code any game their imaginations dream up!

C++ and game development

C++ is a versatile programming language that allows those who master it to be able to solve complex problems and gain a great understanding of how programs function. 

The software kids can use to program in C++ is called Visual Studio, which is an IDE, or Integrated Development Environment. It’s an industry-wide platform with many tools and features to assist! 

With C++ programming skills, kids can make something like an RPG fighting tournament, where they can create, save, and load characters, track character's wins and stats, and code turn-based combat in a loop to decide the winner.

Actions include creating variables, classes, objects, arrays, functions, header files, and more, and then, with graphics, creating animations, frames, and movement.

JavaScript coding

When you consider all of the different kids coding languages and what they’re capable of, it is beyond the scope of this post to go through the many types of video games that can be created. 

So to just give you an idea, take a language like JavaScript, which is a powerful tool capable of creating a number of different types of games, like... 

Top-down shooters

Top-down shooter games heavily focus on gameplay mechanics. These types of games involve the player using long-range attacks and usually include obtaining high scores or collecting something, often while attacking and/or avoiding enemies.

Action-adventure

Action-adventure games focus on gameplay and progression through a story. Coders can also create puzzles or mini-games to further enhance the game. The Legend of Zelda: A Link to the Past is a great example of an action-adventure game with different items to use and enemies to battle.

RPGs

RPGs (role-playing games) are driven by story, but also focus on gameplay. Game heroes will explore dungeons and towns and fight against enemies, including bosses. Creators can plan what kind of equipment and skills are available to enhance the gameplay.

Drag & drop coding options 

Now, while a traditional approach would have your child working with text-based code to make their games, there is also drag-and-drop coding where visual code blocks are used to piece together code for the desired action. 

GameMaker is a powerful game engine where kids can create all kinds of games, ranging from RPGs to 2D Platformers, or even a point and click adventure game. It features a drag and drop coding system that makes programming games easier, as mentioned above. 

And then, of course, Scratch coding for kids is a popular option that can be used to code and build games as well. Again, through block-coding, creators can bring games to life with animation and storytelling! For instance, there are different blocks for movement and sound that coders can easily grab and place into their projects.  

Game design process

Now with the understanding of what options are available when it comes to coding languages, what does the process of designing a game look like? And why is this a necessary step?

Well, in order to code a game, it must first be conceptualized, with the plot and storyline dreamed up, along with settling on other details like levels and environments, character interactions, and more. 

As you can imagine, there are many additional ins and outs that need to be navigated, and a variety of other capabilities available to those wanting to make a working, entertaining title. 

This is stated in order to set expectations, and give creators an idea of how they might be able to traverse the game design process. 

Plan

Planning a project helps provide a path to follow as work unfolds. Having a thought-out plan also serves as an important reference to ensure designers are staying true to their original vision.

Avoid waste

Creating video games takes a lot of valuable resources like time, money, and energy. Proper planning will help eliminate waste. 

Thus, if planning doesn’t take place, designers might discover that a piece of the project just isn't right. If this error is big enough, it could cause the project to be restarted or even potentially stopped. That would be a huge loss of resources!

Pick a theme

The game's theme is simply what the game is about. A strong theme is only a few words, and begins to give life to an idea.

For instance, In The Legend of Zelda: Breath of the Wild, the player spends most of the game exploring on their own. There are many ruins dotting Hyrule; lots of broken machines, and you have to survive against the elements without much help. 

Thus, one possible theme for this type of gameplay could then be “lonely exploration.”

While it's tough to settle on one single theme, games can have multiple themes associated with them. However, no matter how many themes are assigned, there's still one theme at the heart of each game. 

Designers should also keep in mind that multiple themes will add complexity to their game, and will also require additional time and resources to complete. 

Main characters

And while most great games don’t exist without stories, those stories are difficult to put together without characters. 

For instance, imagine Pokémon without any characters. There wouldn’t be any trainers to battle or monsters to collect... just an empty world with lots of vacant gyms and tall grass, without any of the fun you expect from the series!

Digging into the fundamentals of character design is one area where imagination and creativity come into play, so encourage kids to explore:

  • What world does their character come from?
  • What species are they? Are they human?
  • What role does the character play in the story?

Characters are just like people in real life—they have backstories and features that make them unique. 

Game engine intro

So, armed with the next big game idea, how does it get put into action?

A game engine is a software-development environment that allows creators to build video games big and small, and for use on different consoles and devices. 

For instance, Unity is a game engine used to create 2D and 3D games; it can design levels, program scripts, and a whole lot more. Games like Crossy Road, Monument Valley were all made with Unity.

And then, Unreal Engine 4 is also a leading engine in the industry, which has extremely powerful graphics capabilities, high-end lighting, shading, visual effects, and can use virtual reality (VR) systems such as the Oculus Rift. Mass Effect, Gears of War, and Fortnite are just a few of the many games created using the Unreal Engine. 

Definitions

Now, any new coding adventure is going to introduce new terms and jargon kids will probably have to learn and wrap their heads around in order to advance with their learning. 

Here are a few coding terms they can get started with:

Variables 

Variables are a fundamental part of coding, and are used to represent information in a game. Meaning, they are containers in code that can hold a single number, word, and other information. The three different parts of a variable include type, name, and value. For instance, values are frequently used and may change—like a player's name, score, or health.

When the type of variable is specified, like a string, you're telling the program that this “chest” of info can only be filled with words, phrases, and multiple characters. It won't be able to hold numbers, true/false values, and so on. 

For example, imagine your child is coding an RPG where the name of their character is “Blocker.”

Throughout the game there is dialogue that uses the character's name. 

If they were to change the name of the character to "Billy" they’d have to go through every bit of code that mentions their name and change it manually.

This is a tedious task!

But if they had a variable called "name" that stored the name, instead of going into the code and changing every instance of "Blocker" that is mentioned, they would only need to change the name variable once.

Conditions

User interaction can change operations in programs. So, if a statement is true, it will run a specific code, and if it's false, it'll run another set of code. This is made possible through if, else if, and else statements. 

You can present the idea of user interaction as a fork in the road. 

In a game's start menu, the user can press “Start” to launch the game or “Exit” to leave the game. Conditional statements handle these types of interactions. They'll take information and send the user to a certain part of the program.

Loops

Programs generally execute from top to bottom, and as mentioned above, if statements are used to run code if certain conditions are true.

But what if a game coder wants to repeat a section of code multiple times?

Then loops can be used to generate something like hundreds of coins in a game without having to write a hundred lines of code. Instead, one line of code can be written, and then can be looped 100 times!

While Loops

Specifically, while loops allow coders to repeat a block of code an undefined number of times until a condition is met. While loops are set up just like if statements. They check for a condition and run the code in them until the condition is no longer true.

For Loops

For loops allow coders to run a block of code repeatedly, just like while loops. However, for loops run a block of code a set number of times. This is helpful when it’s known just how many times a block of code needs to be run.

Playtesting

When designing a game, it’s always good practice to try to anticipate what someone will be experiencing when playing the finished title. 

What are they going to find fun? Where are the problems in the game?

And while it’s easy to think the answer would be apparent and obvious to the creator themselves, the best way to know for sure is playtesting.

Playtesting is exactly what it sounds like—people play a game to find the fun and see what can be improved. And yes, while anyone can play their own game to test, it’s always best to enlist the help of others. It’s like the chef who is tasting their own food, or the writer proofing their own work.

Meaning, you need “outside” perspective to truly understand what’s good and what needs tweaking.

The first step of many!

As you can see, coding a game is no small activity, and involves a lot more than what has already been explained above, including things like animation, character movement, game space, and other pieces. But that’s what makes a great game so special! 

If your child is interested in coding their own game, check out the resources below, and think about pairing them up with expert help! 

Virtual after-school programs are available now for students wanting to create and socialize with like-minded peers. Those looking for more one-on-one guidance can take part in online tutoring lessons.

A photo of Ryan

Ryan manages blog content at iD Tech, starting with the company in 2008. He earned his MBA from Santa Clara University after obtaining his Bachelor’s degree from Arizona State. Connect on LinkedIn!