Game Development Reference
In-Depth Information
interpreted by another program as it runs. This topic refers to the JavaScript
you are about to learn as being compiled , when in reality at the technical
level it isn't really.
When a program is compiled, it is turned into machine code the computer
can understand. Compilation checks through the code for errors and then
builds it into a program. Don't worry if you get lots of errors when you start
programming. It is a normal part of the learning process. Some of the error
messages will also seem quite vague and ambiguous for what they are
trying to tell you. However, a quick search on Google will often reveal
their true meaning.
JavaScript is used in this topic as the primary means of programming.
Although it is strictly a scripting language, it will be referred to in terms of
programming, as it will be used to add computational functionality to games
developed in Unity. Its syntax and constructs are also closely related to C++,
C#, and Java; therefore, as a beginning language to learn it is ideal. It also
provides a very powerful and yet simple way to develop game mechanics
in Unity and many other game-editing environments.
Several fundamental constructs in programming are required to fully
understand a programming language. These are variables, operations, arrays,
conditions, loops, functions, and objects. However, the most fundamental
and important concept that underlies everything is logic.
1.5.1 Logic
At the heart of all computers are the electronic switches on the circuit
boards that cause them to operate. The fact that electricity has two states,
on or off, is the underlying foundation on which programs are built. In
simplistic terms, switches (otherwise known as relays) are openings that
can either be opened or be closed, representing on and off, respectively.
Imagine a basic circuit illustrated as a battery, electric cable, light switch,
and lightbulb shown in Figure 1.23 .
When the switch is open, the circuit is broken and the electricity is off.
When the switch is closed, the circuit is complete and the electricity is
on. This is exactly how computer circuitry works. Slightly more complex
Fig 1.23 A very basic electric circuit.
on
off
Search Nedrilad ::




Custom Search