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 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 in your laptop hard drive or even in a CD-ROM. There are commands which make a character appear in the middle of a screen. Or when the player hits the up arrow key, make the character jump. When we want to give instructions like this another person, we use a human language like English, Spanish 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. Just like human languages, programming languages can be very different from each other. Many rely on the 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 character moves up. If I want to use the Python programming language, I could write the instructions like what you see on the left. 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 simpler instructions. Eventually, these instructions get translated into machine language, whose alphabet is made of zeros and ones. The processor, which is the computer 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, all of which happen in fractions of a second.
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 character around, I would do something like what you see on the right. So if I wanted my cat to go up five pixels in Scratch, I would snap together two blocks like this. And 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 colour. And also, I can make him– [MEOW] 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, keeping score, and 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, Minecraft? A professional video game might have millions of instructions written by lots of people all working together to bring the game to life. Human languages have the grammar and basic words you can combine together to create things like stories, novels, poems. In the same way, programming languages have the grammar and basic instructions you can combine together to create not only video games but also, animation, simulations, and interactive stories. And video 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.
Have you built a video game? We’d love to hear about it in the comments below!