📄 ch8.htm
字号:
<HTML>
<HEAD>
<TITLE>Chapter 8 -- User Input in Games</TITLE>
<META>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910">
<H1><FONT COLOR=#FF0000>Chapter 8</FONT></H1>
<H1><B><FONT SIZE=5 COLOR=#FF0000>User Input in Games</FONT></B>
</H1>
<P>
<HR WIDTH="100%"></P>
<P>
<H3 ALIGN=CENTER><FONT COLOR="#000000"><FONT SIZE=+2>CONTENTS<A NAME="CONTENTS"></A>
</FONT></FONT></H3>
<UL>
<LI><A HREF="#GamingandUserInput" >Gaming and User Input</A>
<LI><A HREF="#UserInputDevices" >User Input Devices</A>
<UL>
<LI><A HREF="#TheKeyboard" >The Keyboard</A>
<LI><A HREF="#TheMouse" >The Mouse</A>
</UL>
<LI><A HREF="#Summary" >Summary</A>
<LI><A HREF="#QA" >Q&A</A>
<LI><A HREF="#Workshop" >Workshop</A>
<UL>
<LI><A HREF="#Quiz" >Quiz</A>
<LI><A HREF="#Exercises" >Exercises</A>
</UL>
</UL>
<HR>
<P>
Just in case you had a hard weekend, you begin this week with
a pretty easy lesson. Today you learn about user input in games,
including the input devices supported by Java and how they are
used in gaming scenarios. You'll be spared the details of how
to actually communicate with input devices in Java until tomorrow's
lesson. Nevertheless, today's lesson covers some important issues
in regard to game design from a user input perspective.
<P>
Today's lesson serves as a good primer for tomorrow, when you
learn about the specific Java programming techniques necessary
for handling user input in games. For today, though, just relax
and enjoy a break from the source code!
<P>
The following topics are covered in today's lesson:
<UL>
<LI>Gaming and user input
<LI>User input devices
</UL>
<H2><A NAME="GamingandUserInput"><B><FONT SIZE=5 COLOR=#FF0000>Gaming
and User Input</FONT></B></A></H2>
<P>
<I>User input</I> is the means by which the user interacts with
a game.
<P>
Considering the fact that user input encompasses the entire communications
between a player and a game, you would think that designing an
intuitive, efficient interface for user input would be at the
top of the list of key game design elements. However, that isn't
always the case. With all the hype these days surrounding real-time
texture-mapped 3D graphics engines and positional 3D audio in
games, effective user input support is often overlooked. In fact,
user input is perhaps the most overlooked aspect of game design,
which is truly a tragedy. It's a tragedy because user input support
in a game directly impacts the playability of the game; and when
the user input isn't effective, the play suffers.
<P>
You see, I'm from the old school of game players, and I still
remember paying homage to the gods of gaming with my hard earned
allowance in arcades, well before there was an option of playing
anything other than Pong at home. In return for my quarter offerings,
the game gods usually provided me with incredibly fun games that
usually had to survive on their playability alone. Because the
hardware at that time simply couldn't provide a very high level
of graphic and sound intensity, the game developers were forced
to make up for it with game play. Of course, they didn't consider
their focus on playability as making up for anything; with the
limited graphics and sound capabilities at the time, they didn't
have an option.
<P>
Let me give you a quick example of what I'm talking about in regard
to playability and user input. One of my all-time favorite games
is Ring King, which is a boxing game for the Nintendo Entertainment
System (NES). Ring King is definitely considered "old"
by current gaming standards-possibly even ancient. Compared to
current games, it has weak graphics, animation, and sound. However,
I still play the game simply because it plays so well. And that
playability is largely based on how the game handles user input;
it allows for very subtle timing when you punch and dodge, which
goes a long way in a boxing game! Since then, I've tried to find
a modern replacement for Ring King, but I've had no luck. When
I get beyond the fancy graphics and sound, I start missing the
responsiveness of the controls in my old favorite. I'm still looking,
though.
<P>
Lest you think I'm being overly critical of current games, plenty
of recent games have incredible user input support, along with
awesome graphics and sound. However, an equal number of recent
games have killer graphics and sound, but little substance when
it comes to playability and user input. These types of games might
be visually stunning and fun to listen to, but they rarely have
any lasting appeal beyond the initial "Wow!"
<P>
Now, let me step down from the soap box and get to the real point,
which is that you should carefully plan the user input for your
games just like you carefully plan the graphics, sound, and game
logic. This doesn't mean only deciding between supporting a keyboard
or a mouse for the user interface. It means putting some real
thought into making the user interface as intuitive as possible.
You want the controls for the game to feel as natural as possible
to the player.
<H2><A NAME="UserInputDevices"><B><FONT SIZE=5 COLOR=#FF0000>User
Input Devices</FONT></B></A></H2>
<P>
<I>Input devices</I> are the physical hardware, such as mice and
keyboards, that allow a user to interact with a game.
<P>
Input devices all perform the same function: converting information
provided by the user into a form understandable by the computer.
Input devices form the link between the user and your game. Even
though you can't directly control the input device hardware, you
can certainly control how it is interpreted in your game.
<P>
Although some really neat input devices are available for pcs
and Macintoshes, such as flightsticks and digital joysticks, you're
working with Java, so you have to think in terms of supporting
multiple platforms and therefore a fairly limited amount of input
devices. As a matter of fact, the current set of input devices
supported by Java consists of two devices-the keyboard and the
mouse.
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Trackballs have also grown in popularity as input devices recently. Trackballs are functionally very similar to mice and are often treated just like mice from a software perspective. Fortunately, Java doesn't discern between trackballs and mice, so the
mouse support in Java indirectly supports trackballs as well.</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<P>
It might sound limiting to not be able to support joysticks in
Java, but it is simply a fact of life that joysticks aren't considered
a "standard" input device by the computer community
at large. Arguably, it would be nice to be able to support joysticks
as an optional input device, but you'll simply have to hope for
the support in a future release of Java. Even without joystick
support, however, creative user input strategies can still be
implemented. Personally, I like using either the keyboard or mouse
for most games, rather than a joystick. But I'm kind of strange
in that respect!
<P>
<CENTER><TABLE BORDERCOLOR=#000000 BORDER=1 WIDTH=80%>
<TR><TD><B>Note</B></TD></TR>
<TR><TD>
<BLOCKQUOTE>
Sun has announced plans for extensions to the Java language that will include broader multimedia support. It's not clear whether joysticks and other game-oriented input devices will be supported in these extensions, but there is no reason that they
couldn't be supported. We'll just have to wait and see.</BLOCKQUOTE>
</TD></TR>
</TABLE></CENTER>
<P>
<H3><A NAME="TheKeyboard"><B>The Keyboard</B></A></H3>
<P>
The keyboard has been the computer input device of choice since
its inception. Although mice, joysticks, flightsticks, and many
other user input devices have brought extended input capabilities
for the game player, none is as established as the keyboard. At
the bare minimum, you can always count on a game player having
a keyboard.
<H4><B>Usage</B></H4>
<P>
The keyboard is a surprisingly useful input device for a wide
range of games. The sheer amount of keys alone gives the keyboard
appeal for games that require a wide variety of user input. Even
more useful in the keyboard is the natural feel of pressing keys
for games requiring quick firing and movement. This usefulness
is evident in the amount of arcade games that still use buttons,
even when powerful digital joysticks are readily available. Keys
(or buttons) simply are easier to use in many games, including
those with many input combinations.
<P>
When assessing the potential use of the keyboard in a game, try
to think in terms of the most intuitive user interface possible.
For example, any game involving the player moving an object around
would benefit from using the arrow keys. A good example is DOOM,
which makes creative use of a keyboard-specific feature that greatly
enhances the playability of the game. The left and right arrow
keys, when used alone, rotate the player left and right in the
game world. However, when the Shift key is held down, the same
left and right arrow keys cause the player to <I>strafe</I>, meaning
that the player moves sideways without changing direction. This
seemingly small enhancement to the keyboard controls goes a long
way when playing the game.
<P>
When you're deciding on specific keys to use for keyboard controls
in your game, consider the potential limitations on players using
other platforms or hardware configurations. For example, I primarily
use a Windows 95 pc equipped with a Microsoft Natural keyboard.
If you aren't familiar with these keyboards, they are split down
the middle for ergonomic reasons. If you don't use one of these
keyboards, it might not occur to you that key combinations near
the center of the keyboard will be separated a few inches for
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -