Game Development Reference
In-Depth Information
The main task of the processor is to execute instructions . The effect of executing these instructions
is that the memory is changed. Especially with my very broad definition of memory, every
instruction a processor executes changes the memory in some way. You probably don't want the
computer to execute only one instruction. Generally, you have a very long list of instructions to
be executed—“Move this part of the memory over there, clear this part of the memory, draw this
sprite on the screen, check if the player is pressing a key on the gamepad, and make some coffee
while you're at it”—and (as you probably expect) such a list of instructions that is executed by the
computer is called a program .
Programs
In summary, a program is a long list of instructions to change the computer's memory. However, the
program itself is also stored in memory. Before the instructions in the program are executed, they're
stored on a hard disk, a DVD, or a USB flash disk; or in the cloud; or on any other storage medium.
When they need to be executed, the program is moved to the internal memory of the machine.
The instructions that, combined together, form the program need to be expressed in some way.
The computer can't grasp instructions typed in plain English, which is why you need programming
languages such as JavaScript. In practice, the instructions are coded as text, but you need to follow
a very strict way of writing them down, according to a set of rules that defines a programming
language. Many programming languages exist, because when somebody thinks of a slightly better
way of expressing a certain type of instruction, their approach often becomes a new programming
language. It's difficult to say how many programming languages there are, because that depends
on whether you count all the versions and dialects of a language; but suffice to say that there are
thousands.
Fortunately, it's not necessary to learn all these different languages, because they have many
similarities. In the early days, the main goal of programming languages was to use the new
possibilities of computers. However, more recent languages focus on bringing some order to the
chaos that writing programs can cause. Programming languages that share similar properties are
said to belong to the same programming paradigm . A paradigm refers to a set of practices that is
commonly used.
The Early Days: Imperative Programming
A large group of programming languages belongs to the imperative paradigm . Therefore, these
languages are called imperative languages . Imperative languages are based on instructions to
change the computer's memory. As such, they're well suited to the processor-memory model
described in the previous section. JavaScript is an example of an imperative language.
In the early days, programming computer games was a very difficult task that required great skill.
A game console like the popular Atari VCS had only 128 bytes of RAM (Random Access Memory)
and could use cartridges with at most 4,096 bytes of ROM (Read-Only Memory) that had to contain
both the program and the game data. This limited the possibilities considerably. For example, most
games had a symmetric level design because that halved the memory requirements. The machines
were also extremely slow.
 
Search WWH ::




Custom Search