

By using the Windows Runtime, you can poll the current state of the accelerometer device, as well as receive touch events through the Windows Runtime event-handling mechanism. An accelerometer is a sensor that measures the force that is applied along the X, Y, and Z axes. Touch enables applications to track and respond to fingertip input. Marble Maze uses the Windows::Gaming::Input APIs to poll the controller for input. Marble Maze supports the Xbox controller, mouse, and touch to select menu items, and the Xbox controller, mouse, touch, and the accelerometer to control game play. Doing so can simplify how input is interpreted by other components of your game, such as physics simulation, and can make it easier to write games that work on different screen resolutions. For touch, record touch events in data structures that are available to your input processing code.Ĭonsider whether to normalize input values to a common format. That is, you can poll for data when you need it. The Xbox controller and the accelerometer support polling.

Process Windows events before you process input devices. Or, simply track input only from the most recently added controller, as we do in this sample. This way, you don’t have to track what input comes from which controller. The Xbox controller doesn't require initialization.įor single-player games, consider whether to combine input from all possible Xbox controllers. To initialize the accelerometer, create a Windows::Devices::Sensors::Accelerometer object when you initialize the application. To initialize touch, you must register for window events such as when the pointer is activated, released, and moved. We designed the game controller and sensor APIs to help you more easily integrate these input devices.

Although game controller and sensor usage is optional, we strongly recommend it to enhance the player experience. When possible, support multiple input devices to enable your game to accommodate a wider range of preferences and abilities among your customers. Here are some of the key points that this document discusses for when you work with input in your game:
#How to set zone position in any maze code#
The sample code that corresponds to this document is found in the DirectX Marble Maze game sample.
