PC Gaming
  Home arrow PC Gaming arrow Page 2 - Controlling Games with the Keyboard an...
Dev Hardware Forums 
Computer Cases  
Computer Processors  
Computer Systems  
Digital Cameras  
Flat Panels  
Hardware Guides  
Hardware News  
Input Devices  
Memory  
Mobile Devices  
Motherboards  
Networking Hardware  
Opinions  
PC Cooling  
PC Gaming  
PC Speakers  
Peripherals  
Power Supply Units  
Software  
Sound Cards  
Storage Devices  
Tech Interviews  
User Experiences  
Video Cards  
Mobile Linux 
APP Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PC GAMING

Controlling Games with the Keyboard and Mouse
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 30
    2004-10-11

    Table of Contents:
  • Controlling Games with the Keyboard and Mouse
  • Taking a Look at User Input Devices
  • Mouse and Joystick
  • Tracking the Mouse
  • Revamping the Game Engine for Input
  • Sprucing Up the Bitmap Class
  • Building the UFO Example
  • Testing the Finished Product

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Controlling Games with the Keyboard and Mouse - Taking a Look at User Input Devices


    (Page 2 of 8 )

    An input device is the physical hardware that allows a user to interact with a game. Input devices all perform the same function: converting information provided by the user into a form understandable by the computer. Input devices establish the link between the user and your game. Even though you can't directly control the input device hardware, you can certainly control how it is interpreted in your game. As I mentioned earlier, there are three primary types of user input devices:

    • The keyboard

    • The mouse

    • Joysticks


    Note - In case you're wondering, trackballs are functionally very similar to mouse devices and are often treated just like mouse devices from a software perspective. In fact, the Win32 API doesn't discern between trackballs and mouse devices, so the mouse support in your games indirectly supports trackballs as well. Similarly, game pads are classified as joysticks and are treated no differently than joysticks from a programming perspective.


    The next few sections get you acquainted with these devices and their relationship to game user input.

    Accepting Keyboard Input

    The keyboard has been the computer input device of choice since its inception. Although mouse devices, joysticks, flight sticks, game pads, virtual reality gloves, and many other user input devices have brought extended input capabilities to the game player, none is as established as the keyboard. At the bare minimum, you can always count on a game player having a keyboard.

    The keyboard is a surprisingly useful input device for a wide range of games. The sheer number of keys alone gives the keyboard appeal for games that require a wide variety of user input. Even more useful with the keyboard is the natural feel of pressing keys for games requiring quick firing and movement. This usefulness is evident in the number of arcade games that still use buttons, even when powerful digital joysticks are readily available. Keys (or buttons) simply are easier to use in many games, including those with many input combinations.

    When assessing the potential use of the keyboard in a game, try to think in terms of the most intuitive user interface possible. For example, any game involving the player moving an object around would benefit from using the arrow keys. A good example is the classic 3D-shooter Doom, which makes creative use of a keyboard-specific feature that greatly enhances the playability of the game. The left and right arrow keys, when used alone, rotate the player left and right in the game world. However, when the Shift key is held down, the same left and right arrow keys cause the player to strafe, meaning that the player moves sideways without changing direction. This seemingly small enhancement to the keyboard controls goes a long way when playing the game.

    When you're deciding on specific keys to use for keyboard controls in your game, consider the potential limitations on players using other platforms or hardware configurations. For example, I primarily use a Windows XP PC equipped with a Microsoft Natural keyboard. If you aren't familiar with these keyboards, they are split down the middle for ergonomic reasons. If you don't use one of these keyboards, it might not occur to you that key combinations near the center of the keyboard will be separated a few inches for people like me. So, remember that if you use the G and H keys (or other middle keys) in your game, and it plays well for you, it might not work out so well for players with different keyboards.


    Note - In Chapter 1, I mentioned a game called Combat Tanks that I co-developed nearly 10 years ago. Back then, there were no keyboards with split key configurations, so that particular game suffers from keys that are uncomfortably spread out on keyboards such as the Microsoft Natural keyboard. Fortunately, we designed the game with customizable keys, so you can change around the control keys for the game. This is an example of a nice game feature having future unintended significance...always a good thing!


    The most common keys used in games are the arrow keys. If you're writing an action game, you might also have keys for firing and selecting between weapons. When you're deciding on the keys to use, keep in mind things such as the creative usage of the Shift key in Doom. If you can limit the number of primary game control keys by making use of a secondary key, such as Shift, you've made the game controls that much easier to use.


    Note - Just in case you think I'm a bit behind the times by referring to Doom repeatedly, I realize that numerous newer and better first-person shooters are around now. However, I like to point out which games added a new or unique feature to a genre, and in this case, Doom was the first major game I know of that used the strafing feature for moving from side to side.


    SamsThis chapter is from Beginning Game Programming, by Michael Morrison (Sams, ISBN: 0672326590). Check it out at your favorite bookstore today.

    Buy this book now.

    More PC Gaming Articles
    More By Sams Publishing


     

    PC GAMING ARTICLES

    - WoW-ing Online Gamers: What to Expect From t...
    - Age of Conan Review
    - Harnessing Video Game Power for Good
    - Grand Theft Auto IV Review
    - PC Games, a Dying Breed?
    - The Art and Psychology of Gaming
    - Halo 3 Hands On
    - GTA IV: Going Too Far?
    - FEAR Combat Review
    - Prey Review
    - Elder Scrolls IV Oblivion Review
    - PS3: Playing at a Whole New Level
    - F.E.A.R. Video Game Review
    - They Don`t Have to See It to Frag It
    - Do Violent Games Make Violent People?






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT