How to Create Your Own Video Game
It’s me, Carmelo. Video games are fun to play, but have you ever wanted to make one yourself? How can I make a character run and jump on the screen just by pressing some keys, just like websites or the apps on your phone? Video games are just computer programs. We make them by giving instructions to a computer or to a video game console. These instructions can be stored on your laptop’s hard drive or even on a CD-ROM.
For example, you can make a character appear in the middle of the screen or make the character jump when the player hits the up arrow key. When we want to give instructions to another person, we use a human language like English or Italian. Unfortunately, we cannot speak to a computer the same way because, for now, computers can only understand simple instructions, and they’re very picky about the way we word things. In order to give instructions to a computer, we need a programming language.
Understanding Programming Languages
Just like human languages, programming languages can be very different from each other. Many rely on text, so programmers can write words that give instructions to a computer. Let’s say I wanted to create a very simple video game where a character moves around the screen. One of the first things I need to tell the computer is that when I hit a certain key, the cat goes up. If I want to use the Python programming language, I could write the instructions like this:
This language looks foreign, but actually, it’s not that complicated. For example, here is where I say that whenever the computer detects any key press, if the key is the up arrow key, it is to move the player, our cat, 0 pixels horizontally and five pixels up. To understand the directions I just gave it in Python, the computer translates them into many more simpler instructions. Eventually, these instructions get translated into machine language, whose alphabet is made of zeros and ones. The processor, which is the computer’s brain, can understand and execute machine language, sending back the right graphics to the screen. Even a simple instruction like “move up five pixels” gets translated into hundreds or thousands of simpler instructions in machine language before the computer can understand and respond. And all this happens in fractions of a second.
Visual Programming Languages
Other programming languages like Scratch, which is developed here at the MIT Media Lab, are visual programming languages. Instead of using words, in Scratch, you can drag and drop blocks together in order to make something happen on the screen. For example, if I want to move a cat around, I would do something like this:
So if I wanted my cat to go up five pixels in Scratch, I would snap together two blocks like this. I can do the same with the left, down, and right arrow keys. Also, I can play with instructions, and I can say that when I click on the cat, I can change its color. And also, I can make him [MEOW].
Creating Complex Games
A game like Space Invaders looks simple, but it’s not. It includes player movement like what we programmed before, but also characters moving by themselves, music and sounds, shooting, collisions, and keeping score. That’s where programming gets interesting. Making something move up five pixels may not sound very exciting, but basic instructions like this one are the building blocks you can use to create your own video games. What kinds of instructions would you use to create something like a memory game, Tetris, Angry Birds, or Minecraft? A professional video game might have millions of instructions written by lots of people all working together to bring the game to life.
The Grammar of Programming Languages
Human languages have grammar and basic words you can combine together to create things like stories, novels, and poems. In the same way, programming languages have grammar and basic instructions you can combine together to create not only video games but also animations, simulations, and interactive stories. Visual programming languages like Scratch make it easier for anyone to learn how to program. So, instead of just playing video games, now you can make them. So go make one!