Chapter 2. Slapshot! The Interactive Hockey GameThe Slapshot! application. Let's get interactive. Chapter 1, "Making Fish Swim in the Multithreaded Aquarium," was all about the Aquarium application, which is nice to watch but doesn't really let you get in on the action. This chapter is on Slapshot!, an interactive hockey game, where you actually have to do something active, or you'll lose. The code developed in Chapter 1 is going to be leveraged for this chapter, because Slapshot! uses hockey puck sprites, much like the fish in the aquariumonly the pucks move faster. You can see what this game looks like in Figure 2.1. The pucks shown in this figure are zooming around the ice at the speed you choose (varies from very slow to just about unbeatably fast). Your job is to use the mouse with the blocker on the left, as you see in the figure, to keep the pucks out of the goal (represented as a thick red vertical line in the app). The computer's going to play against you on this onethe blocker in front of the goal on the right is run by the code. The score appears near the bottom of the game's window. Can you beat the game? Probably. Until you start increasing the speed anyway…. Figure 2.1. The Slapshot! game in action.Here are some of the things this application does:
So how do you create this game and get it running? The first step, as you might expect, is to build the rink. |