Game Development Reference
In-Depth Information
In languages like C, a main loop is literally a coded loop (like a
loop) that runs until a condition is met. In some
cases, this is also referred to as the state machine because it is the
logic that determines which
the game is in, pregame,
ingame, postgame, etc., and performs the corresponding functions.
In ActionScript, it must be set up differently because a regular loop
would lock up the Flash player waiting for the game to finish.
Because of its animation heritage, Flash works in the context of
frames, much like a movie. It has a frame rate, that is, number of
frames per second that can be defined. When a frame passes, Flash
updates the screen, making it the perfect time to perform logic.
This can seem odd to developers used to other languages, but it
quickly becomes second nature. I
ll discuss game loops further
later, as they will be the driving force behind our game code. In
Chapter 16, I
ll also cover explicit use of a finite state machine (one
with a finite number of predefined states).
Game View
A game can take place from any number of views
often the genre
of a game defines which view to use, but not necessarily. Many
modern action games are first- or third-person views, in which you
see the game world from your character
s perspective or from just
behind them. More casual action and adventure games utilize
views from the side. Other genres such as strategy or racing may
view the action from above. Part of what makes a game compelling
and fun to play is the view you choose to employ. An action game
with lots of fast movement and obstacles would be difficult and
lackluster from a bird
s-eye view, but from a first-person view, it
has an immediacy and intensity that suspends the player
lief. Some game views work better in Flash than in others. Most
any views involving a three-dimensional environment won
well given Flash
s technological performance limitations, but there
are tricks and techniques I
ll discuss later that can be used to
3D in a convincing manner.
Often a game
s environment extends beyond its viewable area. For
instance, in Super Mario Brothers, the game world stretches on for
some distance but only a small portion can be seen at a time.
Because of this, the game scrolls back and forth horizontally with
the player kept within the main viewable area. This same effect can
be used both horizontally and vertically for driving games, strategy
games, etc.
One technique to give a scrolling game environment more
depth and look three-dimensional is to have multiple layers of the
environment scroll at different speeds. This technique is known as
Search Nedrilad ::

Custom Search