Game Development Reference
Listing 1.5 Java
public static void main(String args)
Listing 1.6 PHP
echo "Hello World";
Umberto Eco, the creator of Opera Aperta , described the concept of art
as mechanical relationships between features that can be reorganized to
make a series of distinct works. This too is true of programming. The same
lines of programming code can be reorganized to create many different
programs. Nowhere is this shared art/programming characteristic more
obvious than in fractals.
Fractals are shapes made up of smaller self-similar copies of themselves.
The famous Mandelbrot set or Snowman is shown in Figure 1.2 . The whole
shape is made up of smaller versions of itself. As you look closer you will
be able to spot tens or even hundreds of smaller snowman shapes within
the larger image.
A fractal is constructed from a mathematical algorithm repeated over
and over where the output is interpreted as a point and color on the
computer screen. The Mandelbrot set comes from complex equations,
but not all fractal algorithms require high-level mathematical
knowledge to understand.
The Barnsley fern leaf is the epitome of both the creative side of programming
and algorithmic nature of art. Put simply, the algorithm takes a shape, any
shape, and transforms it four times, as shown in Figure 1.3 . It then takes the
resulting shape and puts it through the same set of transformations. This can
be repeated infinitum; however, around 10 iterations of this process give a
good impression of the resulting image (see Figure 1.4 ).
Creating images with these types of algorithmic approaches is called
procedural or dynamic generation . It is a common method for creating assets
such as terrain, trees, and special effects in games. Although procedural
generation can create game landscapes and other assets before a player
starts playing, procedural generation comes into its own while the game
is being played.