User Interaction: Get into the Game 215
Advanced Interaction: Smiley Explosion
One fun animation that my students and my sons enjoy building is
a scaled-up version of SmileyBounce2.py called SmileyExplosion.py.
It takes the bouncing smiley to a fun new level by allowing the
user to click and drag to create hundreds of bouncing smiley faces
of random sizes that travel in random directions at random speeds.
The effect looks like Figure 9-3. We’ll build this program step by
step; the final version is on page 222.
Figure 9-3: Our next app looks like an explosion of smiley face
balloons bouncing all over the screen.
As you can see, we will have dozens to hundreds of smiley
balloons bouncing all over the screen at any given time, so we’re
going to need to draw graphics quickly and smoothly for hun-
dreds of objects per frame. To achieve this, we’re going to add one
more tool to our toolkit: sprite graphics.
Smiley Sprites
The term sprite goes back to the early days of video games. Moving
graphical objects on the screen were called sprites because they
floated over the background, like the imaginary fairy sprites they
were named after. These light, fast sprite graphics enabled the
quick, smooth animation that made video games so popular.