The Best of Creative Computing Volume 2 (published 1977)

Page 38 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails
This book is also available for the Kindle

A Smalltalk Airplane Simulation (how the flight simulator works)

graphic of page

[Image]
****

3. Selecting a command from the menu (bottom right of screen) - command word is
inverted when pointed to. I am
pointing at 'neutral,' a command to reset any control.

****

define what you mean by a group of objects by specifying the action each member
of the group can take and describing properties that distinguish each member of
the group.

Since there are many different instruments in an airplane, but they do nearly
the same thing, l defined one class called instrument and created instances of
that class for the different types of instruments. Each instrument is totally
individual, but still retains the characteristics of the class. For example,
each has its own location on the screen, a label for the instrument, and a value
to display. Each instrument understands certain messages. Each does the same
thing when it receives that particular message, but each instrument can be
controlled individually. Each instance is different from another instance in the
sense that
each has different characteristics. However, each instance of the class called
instrument has the same general form. A common example is the class of human
beings. Every person is a human being, but each person may have different hair
color, height, and weight.

The airplane simulator uses the mouse, keyset, and the keyboard together to send
messages to the airplane to
control its instruments, The mouse controls the position of the stick for pitch
and roll, and it is used to select items from a menu of commands. A menu is a
list of commands that can be executed by pointing at the command word with the
mouse and pushing a button (Picture number 3). The keyset controls the setting
of the rudder pedals and throttle, and uses different combinations of the five
keys to control other operations in the simulator. At this time, the user sets
the controls and requests a display of the state of the airplane with these
control settings.

Later, I will have the airplane continually change state. Now that l have
created the class airplane (the set of instruments and their display), I can
create many instances, each running on a different computer. I hope to change
the program so that other computers in the room can communicate with each other
for a dogfight situation, complete with missiles and a working radar. The
ultimate version of the simulator will have a more insteresting horizon that
will change with the heading of the airplane (i.e., a total 360 degree panorama
can be seen, including mountains and rivers) complete with perspective so that
the actual position of the airplane relative to objects is more apparent.

****

4. The whole screen is inverted - black changes to white and vice versa,
****

Smalltalk is a very easy language to work with, with no limits to the complexity
of programs. The concept of
classes and instances is a very powerful idea and can be used very easily to
simplify very complex problems. This is just not possible in Basic, no matter
how advanced the version is. Therefore, a normal Basic program will probably
look more complex than the same program written in Smalltalk, and, therefore,
most likely harder to understand. The line-by-line execution of Basic is harder
to understand, with the problem of if. . .thens and gotos interrupting the flow
of the program. If this simulation was written in Basic, just for the
instruments there would have to be vectors storing the values of the instruments
and their labels, since all
variables are local in Basic, and any part of the program that would access the
instrument's data would have to know which vector and what element of the
vector. ln Smalltalk, only the class would have to know the explicit details of
where all the data was. By using nesting and different levels in the program,
Smalltalk eliminates the problem of having to jump around in the program because
of a conditional statement or goto. Overall, I think that Smalltalk is easier,
more efficient, and more interesting to use than Basic.

****
[Image]

5. Just before a crash, You can't see the horizon because the airplane is facing
the ground.

Page 38 << PREVIOUS >> NEXT Jump to page:
Go to contents Go to thumbnails
This book is also available for the Kindle