Chapter 11. Input Handling

In this chapter, we will cover:

  • Handling keyboard and mouse input
  • Implementing an abstraction layer for supporting multiple input methods
  • Handling input from an Xbox 360 controller
  • Recording and simulating user input
  • Reading audio data from a microphone
  • Reading video data from a webcam
  • Reading input data from a network

Introduction

The one important feature that sets video games apart from other media like movies or books is the player's ability to interact and be a part of the experience. Just think about it for a moment: A piece of literature defines itself by what it tells and which images it creates in the reader's imagination. Movies are trying to engage and entertain by showing, not telling. The video game medium, while of course being able to tell stories and visualize the action in spectacular ways, requires its audience to take an active part and take control of what's happening on the screen. This is a fundamental difference to the other forms of entertainment media, where the audience is put into the role of a passive consumer. Reading user input and providing immediate on-screen responses, representing the state of the game and prompting the player for more input, this feedback loop operates at the core of every video game.

Input data can originate from various sources and take many different forms. Be it binary data from keyboard and mouse buttons, the absolute two-dimensional screen position of a mouse pointer, or the normalized distance and direction an analog stick is being tilted. Apart from the classic and widely used standard input methods, designers also have found uses for more complex devices, like microphones and cameras, to immerse players even further.

Panda3D provides nice wrappers around most of the details of handling all of these different devices. This chapter will discuss and show how to use these abstraction layers and how to process the provided data to create measures of interaction.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset