HTML and CSS Reference
In-Depth Information
CHAPTER 9
Combining Bitmaps and Sound
Geo Blaster Basic
was constructed using pure paths for drawing. In its creation, we
began to cover some game-application-related topics, such as basic collision detection
and state machines. In this chapter, we will focus on using bitmaps and tile sheets
for our game graphics, and we will also add sound using techniques introduced in
Chapter 7
.
Along the way, we will update the
FrameRateCounter
from
Chapter 8
by adding in a
“step timer.” We will also examine how we can eliminate the use of a tile sheet for
rotations by precreating an array of
imageData
instances using the
getImageData()
and
putImageData()
Canvas functions.
In the second half of this chapter, we will create another small turn-based strategy game
using bitmaps. This game will be roughly based on the classic computer game
Daleks
.
Geo Blaster Extended
We will create a new game,
Geo Blaster Extended
, by adding bitmaps and sound to the
Geo Blaster Basic
game from
Chapter 8
. Much of the game logic will be the same, but
adding bitmaps to replace paths will enable us to optimize the game for rendering.
Optimized rendering is very important when you are targeting limited-processor devi-
ces, such as mobile phones. We will also add sound to
Geo Blaster Extended
, and apply
an object pool to the particles used for game explosions.
Figure 9-1
shows an example
screen of the finished game.