Understanding Animation
Before
getting into animation as it relates to mobile games, it’s important to
understand the basics of what animation is and how it works. Let’s
begin by asking this fundamental question: What is animation? Put
simply, animation is the illusion of movement. Could it be that every
animation you’ve ever seen is really just an illusion? That’s exactly
right! And probably the most surprising animated illusion is one that
captured attentions long before computers—the television. When you watch
television, you see a lot of things moving around. But what you
perceive as movement is really just a trick being played on your eyes.
Animation and Frame Rate
In the case of
television, the illusion of movement is created when a rapid succession
of images is displayed with slight changes in their appearance. The
human eye perceives these changes as movement because of its low visual
acuity, which means that your eyes are fairly easy to trick into
believing the illusion of animation. More specifically, the human eye
can be tricked into perceiving animated movement with as low as 12
frames of movement per second. It should come as no surprise that this
animation speed is the minimum target speed for most computer games.
Animation speed is measured in frames per second (fps).
Although 12fps is
technically enough to fool your eyes into seeing animation, animations
at speeds this low often end up looking somewhat jerky. Therefore, most
professional animations use a higher frame rate. Television, for
example, uses 30fps. When you go to the movies, you see motion pictures
at about 24fps. It’s pretty apparent that these frame rates are more
than enough to captivate your attention and successfully create the
illusion of movement.
Gamer’s Garage
The
reason for the difference between film and television frame rates has
to do more with technical necessity than careful design or planning. In
its early days, film speeds were as low as 16fps, but were eventually
standardized at 24fps, which turned out being a good frame rate to
accommodate sound reproduction. American television, also known as NTSC
(National Television Standards Committee), came along later, and relied
on the power line frequency as a timing reference. This frequency was
(and still is) 60Hz, which results in a frame rate of 30fps. The fact
that film and television frame rates are different means that films have
to be converted to be shown on television. |
Unlike
television and motion pictures, mobile games are considerably more
limited when it comes to frame rate. Higher frame rates in games
correspond to much higher processor overhead, so mobile game developers
are left to balance the frame rate against the limited system speed and
resources. You may find yourself in the position of having to use
simpler graphics in a game so that you can increase its frame rate and
generate smoother animations.
When programming
animation in mobile games, you typically can manipulate the frame rate a
reasonable amount. The most obvious limitation on frame rate is the
speed at which the mobile phone can generate and display the animation
frames. Actually, the same limitation must be dealt with by game
developers, regardless of the programming language or platform. When
determining the frame rate for a game, you usually have some give and
take in establishing a low enough frame rate to yield a smooth
animation, while not bogging down the processor and overloading the
system. But don’t worry too much about this right now. For now, just
keep in mind that when programming animation for games, you are acting
as a magician creating the illusion of movement.
Making the Move to Computer Animation
Most of the
techniques used in computer animation have been borrowed or based on
traditional animation techniques developed for animated films. The
classic approach to handling traditional animation is to draw a
background image separately from the animated objects that will be
moving in the foreground. The animated objects are then drawn on clear
celluloid sheets so that they can be overlaid on the background and
moved independently. This type of animation is referred to as cel animation.
Cel animation enables artists to save a great deal of time by drawing
only the specific objects that change shape or position from one frame
to the next. This explains why so many animated movies have detailed
backgrounds with relatively simple animated characters.
As computer power improved
in the last two decades, traditional animators saw the potential for
automating many of their hands-on techniques. Computers enabled them to
scan in drawings and overlay them with transparency, for example. This
is a similar approach to cel animation, but with one big difference: The
computer imposes no limitations on the number of overlaid images. Cel
animation is limited because only so many cel sheets can be overlaid.
The technique of overlaying objects with transparency is a fundamental
form of computer game animation, as you soon find out.
Gamer’s Garage
Modern animated movies have officially proven that computer animation is for more than just games. Popular movies such as Toy Story, Ice Age, Monsters, Inc., Finding Nemo, and The Incredibles
are great examples of how traditional animated movies are now being
created solely on computers. Perhaps an even more advanced example of
computer animation in movies is Final Fantasy, which is one of the first movies to use computer animation to simulate live action graphics throughout an entire film. |
Although computers
have certainly improved upon traditional animation techniques, the
animation potential available to the game programmer is far more
flexible than traditional techniques. As a programmer, you have access
to each individual pixel of each bitmap image, and you can manipulate
each of them to your heart’s desire.
2D Versus 3D Animation
There are two fundamental
types of animation that you might consider using when creating mobile
games: 2D and 3D. 2D animation involves objects moving or being
manipulated within two dimensions. Objects in a 2D animation can still
have a 3D look to them—they just can’t physically move in three
dimensions. Many 2D animation techniques simulate 3D animation by
altering the look of objects to simulate depth, but they aren’t truly
3D. As an example, an animation of a car driving off into the distance
would involve the car getting smaller as it gets farther away. However,
this isn’t necessarily a 3D animation because you can achieve the 3D
effect by making the car image get smaller as it moves away. Although
the end result is three-dimensional, the car is very much a 2D object.
Unlike 2D animation, 3D
animation involves placing and manipulating objects in a
three-dimensional virtual world. A 3D object is defined by a model
rather than an image because an image is inherently two-dimensional. A
3D model specifies the shape of an object by a series of points, or
vertices, in 3D space. In other words, a 3D model is a mathematical
representation of a physical object. For this reason, 3D graphics and
animation can get extremely complicated because they often rely on
heavy-duty mathematical processing.
In reality, many games
make use of a mixture of 2D and 3D graphics and animation. For example,
the original Doom game uses 3D graphics for the building interiors.
However, the monsters in the game are 2D graphics objects. The monsters
have a 3D appearance, but they are represented by flat images on the
screen.
This
mixture of 2D and 3D graphics works great in Doom because the 2D
monsters look realistic enough when blending into 3D surroundings. Of
course, things have evolved since the original Doom game. Quake and
other more modern 3D first-person shooters (FPS) now use 3D objects
throughout the game.