Game Development Reference
Accelerometers are a good introduction to a class of electronic components called
microelectromechanical systems (MEMS). An accelerometer can either be one-axis, two-
axis, or three-axis. This designates how many different directions it can simultaneously
measure acceleration. Most gaming devices have three-axis accelerometers.
As far as game development is concerned, acceleration values are typically delivered to
your program via an API with units in multiples of g . One g is equal to the acceleration
caused by gravity on the Earth, or 9.8 m/s 2 . Let's pretend that we have a one-axis accel‐
erometer and we orient it such that the axis is pointing toward the center of the earth.
It would register 1 g . Now, if we travel far away from any mass, such that there is no
gravity, the accelerometer will read 0. If we then accelerate it such that in one second it
goes from 0 m/s to 9.8 m/s, the accelerometer will read a steady 1 g during that one-
second interval. Indeed, it is impossible to tell the difference between acceleration due
to gravity and acceleration due to changing velocity.
Real-life motion is generally nonsteady. Depending on your application's goals, you
might have to apply different smoothing functions such as high-pass or low-pass fil‐
ters . This amounts to digital signal processing , a topic that has consumed entire texts.
One example we can recommend is Digital Signal Processing: A Computer Science Per‐
spective by Jonathan Y. Stein (Wiley).
Also, many accelerometers have a method to set the polling rate , or the number of times
per second that the program requests updates from the accelerometer. This is called
frequency and is given in hertz (Hz). This parameter can be used to enhance the per‐
formance of the program when fine resolution of the acceleration over time is not
When you accept input from an accelerometer—or do any other kind of signal pro‐
cessing—you have to accept that input won't come precisely when you want it. The
operating systems normally used for gaming—Windows, OS X, Linux—are not real-