Workshop The Workshop is designed to help you
Workshop The Workshop is designed to help you anticipate possible questions, review what you’ve learned, and begin learning how to put your knowledge into practice. The answers to the quiz can be found in Appendix A, “Quiz Answers.” Quiz 1: If you had to choose between supporting the keyboard or the mouse, which would you choose? 2: What do you have to do differently in a game to support trackballs? 3: Why is it important to extract information from the lParam argument when responding to a mouse message? Exercises 1. Experiment with different values for the _iMAXSPEED global variable in the UFO program example to see how it affects the flying saucer’s speed. 2. Modify the UFO program example so that you can click and drag the mouse to move the flying saucer around. 3. Modify the UFO program example so that the flying saucer wraps off the screen and appears on the other side when it reaches a side edge. Hour 7. Improving Input with Joysticks From its inception, the joystick has been used chiefly as an input device for game systems. Admittedly, its name alone limits its usage to the entertainment industry, as I doubt too many accountants would purchase a “joystick” for crunching numbers in a spreadsheet. At any rate, joysticks and game pads both play an important role in modern video games of all kinds, including computer games. For this reason, it’s important for you to have an understanding of how to interpret and respond to joystick input in your own games. This hour introduces you to joysticks and what makes them tick, along with providing you with the knowledge and source code to handle joystick input in games. In this hour, you’ll learn: The basics of responding to joystick input in games How to properly calibrate a joystick in Windows XP How to add joystick support to the game engine How to use the new and improved game engine to create interesting programs that respond to a joystick Joystick Basics The concept of a joystick is straightforward, although you might be surprised by how loosely a joystick is defined in terms of Windows programming. In Windows, a joystick is a physical input device that allows variable movement along different axes with multiple pushbuttons. That’s the geeky description of a joystick. What it means is that a joystick is an input device that can move in several different directions. Notice that I said several directions, not just two. Although a traditional joystick is thought of in terms of two axes (X and Y), a joystick in Windows can actually go up to six axes. Fortunately, we aren’t going to worry about more than two joystick axes in this hour, which helps simplify things considerably. The six possible joystick axes supported by Windows can be arranged in many different ways. A traditional joystick has two axes that correspond to moving the joystick handle side to side (one axis) and forward and back (another axis). A third axis of movement can be added
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Cheap Web Hosting services