Game Development Reference
In-Depth Information
Let's look at a practical example of how to dispatch events in a game.
Case study: Space Shooter
The chapter's source files contain a folder called Ol]_aOdkkpan. Open it as a project and test it. It's
a very simple prototype of a space-shooter game. Figure 10-24 shows what the Space Shooter game
looks like.
Figure 10-24. Space Shooter prototype
The player can fly around the screen and shoot the robot. The robot rotates toward and then follows
the player; and fires bullets. The scoreboards at the top of the stage keep track of the number of hits
each has achieved. The number of bullets on the stage is also displayed.
The Lh]uan class uses a control scheme that is based on the easing system you looked at earlier in the
chapter. In this system, the fairy's wand is used as the point that follows the mouse.
The Nk^kp class makes the robot follow the player and also rotate toward and shoot at it. This is one
more combination of the two techniques discussed earlier in the chapter.
Take a look at both these classes to see how they work. In both cases, they use no new techniques.
What is new in this game, however, is the way events are used.
The most important thing about this game is how the bullet objects are being managed with the use
of events. Let's take a detailed look at how this works.
 
Search Nedrilad ::




Custom Search