Sha256: 34ba24ee5b4483aa130e5f2ecd1ce2cda5fe191b4f7fb2becec50242c6a58d3f

Contents?: true

Size: 979 Bytes

Versions: 25

Compression:

Stored size: 979 Bytes

Contents

// Thanks for inspiration to Phil Cooper-King.
// This is adapted from his MIT-licensed Gosu fork
// on GitHub.

#import <GosuImpl/Input/AccelerometerReader.hpp>

@implementation AccelerometerReader
- (AccelerometerReader*)initWithUpdateInterval: (float)updateInterval
{
    if (self = [super init])
    {
        [[UIAccelerometer sharedAccelerometer] setUpdateInterval: updateInterval];
        [[UIAccelerometer sharedAccelerometer] setDelegate:self];
        acceleration[0] = acceleration[1] = acceleration[2] = 0.0f;
    }
    return self;
}

- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)uiAccel
{
    float factor = 0.3f;
    acceleration[0] = (uiAccel.x * factor) + (acceleration[0] * (1 - factor));
    acceleration[1] = (uiAccel.y * factor) + (acceleration[1] * (1 - factor));
    acceleration[2] = (uiAccel.z * factor) + (acceleration[2] * (1 - factor));
}

- (const Acceleration&)acceleration
{
    return acceleration;
}
@end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
gosu-0.7.47.1 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.46 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.45 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.44 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.43 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.41 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.40 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.39 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.38 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.37 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.36.2 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.35 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.33 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.32 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.31 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.30 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.29 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.28 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.27.1 GosuImpl/Input/AccelerometerReader.mm
gosu-0.7.27 GosuImpl/Input/AccelerometerReader.mm