new saucer position (line 8 ). The flying
argument of the MouseButtonDown() function so that it can convey more than two values one for each of the three mouse buttons. Testing the Finished Product The UFO program example is the closest thing you’ve seen to a game thus far, and is quite interesting in terms of allowing you to fly around an animated graphical object. Hopefully, you’ll be pleasantly surprised by the responsiveness of the program’s keyboard controls. Figure 6.1 shows the UFO program in action as the flying saucer does a flyby of some desert cacti. Figure 6.1. The UFO program example demonstrates how to control an animated graphical object with the keyboard and mouse. If you guide the flying saucer to the edge of the game screen, it will stop, which is to be expected given the program code you just worked through. There are a variety of different ways to tweak this program and make it more intriguing, such as wrapping the flying saucer from one side of the screen to the other, which is why I hope you spend some time tinkering with the code. You’ll find some ideas for modifying the program in the Exercises for the lesson, which are coming up. Summary The ability to effectively communicate with the people that play your games is a critical factor of game design and development. In one direction a game communicates by displaying graphics and playing sounds and music, but in the other direction the user responds by interacting with a physical input device of some sort. It’s very important for game developers to master the fine art of responding to user input through a variety of different user input devices. The keyboard and mouse are the two fundamental user input devices that you can count on virtually all people having. This hour showed you how to handle and respond to keyboard and mouse input in an efficient manner specifically suited to games. Beyond the keyboard and mouse, it’s up to your resources and the specific needs of each game to determine whether you should support additional input devices. Hour 7 tackles the subject of joystick input, which is the next most important input device for games. Q&A Q1: Are there any games that wouldn’t require keyboard support? A1: Sure. Any game that requires extensive point-and-click style input, such as a card game, would probably be fine without any keyboard support. In fact, you create a memory game in Hour 8, “Example Game: Brainiac,” that is perfectly suited for mouse input alone. However, if you can figure out a way to add keyboard controls to mouse-centric games, by all means go for it. Q2: Is it possible to mix keyboard and mouse controls? A2: Of course! This actually hits on an interesting point not directly covered in this hour: Many games work great by combining mouse and keyboard controls together. A good example is the strafing feature in Doom, which also works with the mouse; it is activated by holding down the Shift key while moving the mouse left or right.
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost Clan Web Hosting services