Game Development Reference
In-Depth Information
The variables accX , accY , and accZ are the smoothed accelerometer values that
we will use in our program for input. The lSmoothFactor value determines how
much smoothing we are applying to the inputs. If it is set to IW_GEOM_ONE , no
smoothing will be applied and the results will be exactly what is coming in from
the accelerometers.
Lower values for the smoothing factor will generate less jittery input values, but this
will be at the expense of adding a certain amount of lag to the inputs. The degree of
lag depends on how often the smoothing code is executed, which in turn depends on
the frame rate of your game.
Working out a good value to use for the smoothing factor is really just a case of
trial and error. You just need to keep tweaking the value until you achieve a
suitable result.
IW_FIXED_MUL is a useful function provided by Marmalade for
doing fixed point multiplication where IW_GEOM_ONE (4096) is
equivalent to one. It multiplies the two parameters together and
then shifts the result back down to be in the correct range.
Testing accelerometer input on the Windows
simulator
Given that computers don't tend to feature accelerometer inputs of any kind,
testing this form of input in the Windows simulator may appear to be impossible.
Fortunately, Marmalade does provide us with a way of doing so.
When running an application in the simulator, select the menu item Configuration
| Accelerometer… and a window showing a small 3D representation of a mobile
device will be displayed:
 
Search WWH ::




Custom Search