O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting motion using an accelerometer

There are several applications and games that can be controlled by tilting a device. For example, such a mechanism can be used to steer a car or to control a ball that should be located in some specific place on a board. Have you even seen such a solution? Have you wondered how it is possible and whether it is difficult to implement?

If so, this recipe will answer such questions, because here you will learn how to use an accelerometer to read G-force values along the x, y, and z axes. Such values will be used to steer a ball that can freely move on the board, of course, restricted by screen bounds. What is more, the ball should behave quite naturally, that is, it should move faster when the tilting is greater. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required