Computers don’t do anything without someone telling them what to do, much like the average teenager. To make the computer do something useful, you must give it instructions in either of the following two ways: Write a program, which tells a computer what to do, step-by-step, much as you write out a recipe. Buy a program that someone else has already written that tells the computer what to do. Ultimately, to get a computer to do something useful, you (or somebody else) must write a program.
A program does nothing more than tell the computer how to accept some type of input, manipulate that input, and spit it back out again in some form that humans find useful. Table 1-1 lists some common types of programs, the type of input that they accept, and the output that they produce. Essentially, a program tells the computer how to solve a specific problem. Because the world is full of problems, the number and variety of programs that people can write for computers is practically endless. But to tell a computer how to solve one big problem, you usually must tell the computer how to solve a bunch of little problems that make up the bigger problem.
If you want to make your own video game, for example, you need to solve some of the following problems: Determine how far to move a cartoon figure (such as a car, a spaceship, or a man) on-screen as the user moves a joystick. Detect whether the cartoon figure bumps into a wall, falls off a cliff, or runs into another cartoon figure on-screen. Make sure that the cartoon figure doesn’t make any illegal moves, such as walking through a wall. Draw the terrain surrounding the cartoon figure and make sure that if the cartoon figure walks behind an object such as a tree, the tree realistically blocks the figure from sight.
Determine whether bullets that another cartoon figure fires are hitting the player’s cartoon figure. If so, determine the amount of damage, how it affects the movement of the damaged cartoon figure, and how the damage appears on-screen.