This appendix contains answers to the quiz questions presented
at the end of each lesson. Please refer to these answers to check
your own answers to the questions. I would tell you to feel free
to grade yourself, but this is supposed to be fun!
CompuServe created the GIF image format in 1987 as a means
to establish platform-independence in graphical images.
The technique of storing an image so that it can be drawn
incrementally as it is being loaded. Interlacing is used frequently
in Web page images.
The process of reducing the colors in an image to a lesser
number of colors, while still maintaining a similar look.
A graphical object with multiple animation frames, which are
also known as phases of the object.
Decide how much you can afford to pay for the artwork, find
out if the artist has experience with computer graphics, and develop
a good idea of what specific artwork you want the artist to create.
The illusion of movement is created by displaying images in
rapid succession with small changes in content between each.
Frame-based animation and cast-based (sprite) animation.
Transparency is a technique used to draw only the relevant
part of a rectangular image. This is extremely useful in sprite
animation, where many objects have irregular shapes yet are modeled
as rectangular images.
Flicker is the annoying phenomenon created when the screen
is erased between each frame of an animation sequence. This is
caused by the rapid combination of erasing and then drawing the
next frame, and it can be fixed only by eliminating the requirement
of erasing the screen.
Double buffering is a technique that helps eliminate flicker
when displaying an animation. It involves drawing the next frame
of animation to an offscreen buffer and then drawing the buffer
to the screen. This eliminates flicker because the screen never
has to be erased; the offscreen buffer is erased with each new
frame.
By the integers 0 to 7, where 0 represents 0 degrees (facing
up) and each other integer represents angles increasing by 45
degrees each time. For example, 3 represents 135 degrees and 4
represents 180 degrees.
The velocity multipliers are used to alter the velocity based
on the direction. For example, if the direction is 2, the angle
is 90 degrees and the sprite is facing right. Therefore, the X
velocity needs to be positive and the Y velocity needs to be zero.
In the update method
of the Tarantula class, the
decision of whether to create new spiderlings is determined in
a completely random fashion.
The same way that they determine whether to create spiderlings:
randomly via the update method.
Two reasons. First, because you want to limit to 10 the number
of sprites that could be added to the list. Second, because you
want to eliminate collision detection and let the tarantulas walk
all over each other.
Sorry, this was a little bit of a trick question. The answer
is whichever one works best! The point is that there are no hard
rules when determining the best user input approach in games.
In Java, it's not! This is a little inside joke for DOS (yikes!)
game programmers. Fortunately, Java frees you from the burdens
of low-level, processor-specific coding such as interrupt routines,
and it lets you deal with input at a more meaningful level.
An event is simply something that happens that you might want
to know about.
Call the shiftDown method
on the Event object that
is passed into the mouseMove
event handler method.
By overriding the mouseExit
event handler method.
The keyboard controls for the saucer are implemented by overriding
the keyDown event handler
method and setting the velocity of the saucer according to which
arrow key was pressed. The mouse controls for the saucer are implemented
by overriding the mouseDown
and mouseDrag methods and
setting the position of the saucer based on the mouse position.
The keyDown event handler
method is used to detect when the arrow keys are pressed. If an
arrow key is pressed, the gecko's velocity is set accordingly.
To only allow one movement per key press, the gecko's velocity
is reset to zero in the update
method for Gecko.
Pretty well. Geckos are extremely fast-much faster than your
Java-handicapped gecko.
By overriding the action
method and checking to see whether the event target is of type
Button. If so, the arg
parameter is cast to a String
and compared to the string "New
Game". If there is a match, the button was indeed
pressed, so the newGame method
is called.
Unfortunately, the answer is no. You'll have to wait for a
future release of Java to remedy this situation. However, all
is not lost, because on Chapter 11 you learned that many popular sound
editing tools enable you to convert sounds across a wide variety
of formats.
The getCodeBase method
returns the base URL for the location of the current applet, whereas
the getDocumentBase method
returns the base URL for location of the HTML document containing
the applet. Because resources such as sounds are typically stored
relative to the applet, it is both safer and smarter to use getCodeBase
when you need a URL for loading a resource.
When you need to play a looped sound or when you plan on playing
a sound more than once.
By calling the stop method
on the AudioClip object used
to loop the sound.
Because you need to be able to ignore the net sprite when
looking to see whether the player clicked a scorpion. It also
enables you to override the default response to collision detections.
Because they're nocturnal creatures.
Because it is necessary to stop the looped music when the
update thread is stopped. Otherwise, it would be possible for
the music to keep playing even though the rest of the applet was
stopped.
Because it must be accessible by other classes. More specifically,
the lost member variable
is incremented in the update
method of the Scorpion class.
Different behaviors are assigned probabilities for an object
and then selected based on these probabilities; each behavior
represents a particular type of action for an object, such as
fighting or fleeing.
Calculating a score based on the current state of the game.
Because hardware has only recently reached a point where it
can begin dealing with the heavy amount of processing required
of most AI systems.
The map is used to provide an efficient and logical way of
representing all the different winning scenarios in the game.
Without the map, you would have a significantly more difficult
time calculating scores and determining whether a player has won.
Because it logically makes sense to divide it into two separate
components. More important, however, is the fact that Connect4State
must be able to be copied and used temporarily in a recursive
manner. This usage wouldn't be possible if everything was combined
in a single class.
Because the computer player's thinking algorithm is not implemented
in a thread. This results in the algorithm tying up the system
while it is running. Because the system is tied up, the screen
isn't updated and, therefore, the hand selector isn't drawn.
From a strictly game design perspective, there is no difference.
The difference arises when you assess the bandwidth limitations
of each. Modem connections have much smaller bandwidths than physical
connections.
State synchronization, input synchronization, and hybrid.
A software abstraction that represents a communication channel
for a particular service such as FTP or HTTP.
Sockets are significant to network programming because they
allow you to focus on input and output operations, independent
of the intricacies and specifics involved with the network itself.
Stream sockets act like active connections, with data being
transferred immediately in real time; datagram sockets just broadcast
data over the Internet and hope that it eventually makes it to
the intended destination at some point in the future.
The generic socket class is important because it isolates
the common code involved in establishing general communications
between clients and a server. This code can be easily reused in
more specific client/server classes designed to support a particular
game.
A daemon thread is a thread that runs in the background and
performs some type of support function, such as managing client
communications in the NetConnect4 game.
The Game class handles
the details of managing the game logic and the communication between
players from the server side.
The Connect4ClientConnection
class handles establishing a client socket connection, along with
managing the communication between players from the client's perspective.
A profiler helps you isolate which code is being called the
most and how much time is being spent there, which tells you where
to direct your optimization efforts.
When your code is reliant on costly calculations that can
be replaced with a table of integer constants.
The one that works for you! That's no joke, because a development
tool is only useful to the degree that it saves you time and energy.
Research the tools for yourself and decide which, if any, of them
might suit your needs.
Rest and relaxation! Come on, you've finished the guide; go
have a little fun and unwind!