Improving Input with Joysticks - Testing the Finished Product
(Page 7 of 7 )
If you haven't done so already, I encourage you to plug in your joystick and take the UFO 2 program for a test spin. You'll hopefully find that the joystick controls for the program have a surprisingly good feel, considering that the joystick handling code in the program is relatively simple. Try pressing the two primary buttons on the joystick to get a feel for the thrust and hyperspace features of the program. Figure 7.7 shows the flying saucer as it appears with the flaming thrust beneath it.

Figure 7.7 -- The flying saucer in the UFO 2 example shows off its new thrusting capabilities.
Tip - If the flying saucer immediately starts moving without you touching the joystick, it's a pretty good sign that your joystick needs to be calibrated. Revisit the earlier section "Calibrating Joysticks," to find out how to calibrate your joystick and eliminate this problem.
Granted, you might have a valid concern as to why the flying saucer visually thrusts but doesn't seem to have any additional lift when you press the thrust button. This is something I challenge you to solve as an exercise on your own; just kick up the vertical speed of the saucer a bit when the thrust button is pressed. You might also have noticed that hyperspace is quite sensitive. In fact, the hyperspace feature reveals how fast the game engine's joystick processing actually is.
Summary
Although joysticks don't quite share the widespread acceptance on PCs that keyboards and mouse devices do, they are the quintessential user input device for games. There aren't too many serious gamers who don't have a joystick or game pad. However, you don't have to be serious about games to enjoy the benefits of playing games with a joystick. For this reason and more, it's a good idea to try and support joysticks in games for which it makes sense to use a joystick for input. This chapter gave you the nuts and bolts of Windows joystick handling and even showed you how to build it into the ever-evolving game engine. You also saw how easy it is to add joystick support to an existing program.
Mark your calendar because Chapter 8, "Example Game: Light Cycles," represents a significant milestone in your game programming career—you develop your first complete action game. Even though the Brainiac game in the previous chapter was technically your first game, moving into the action realm is a huge step forward.
Field Trip
I realize that the people at your local computer store might be starting to get suspicious of your repeated trips, but a wealth of knowledge for learning about games can be found there. More specifically, I'd like you return yet again for a joystick reconnaissance mission. In case you haven't noticed, joystick technology has come a long way in recent years. As an aspiring game programming guru, it's important for you to have a solid base of knowledge about what's available in the way of modern joysticks. As you study the different joysticks on the shelves, pay particular attention to the number of buttons and their arrangement. If you already have a game in your mind that you're working on, see if you can figure out how to best make use of the joystick hardware available. Don't forget that it's possible to use only a few joystick buttons for basic game operations and then reserve additional buttons for more advanced features. Game players like to have options, and by intimately understanding the game controller marketplace, you'll be better prepared to provide them with those options.
This chapter is from Beginning Game Programming, by Michael Morrison (Sams, ISBN: 0672326590). Check it out at your favorite bookstore today.
Buy this book now. |
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |