Determine tilt angle from reference point using accelerometer.
Spent a bit of time trying to figure this out so thought I'd just share here. If you want to determine the angle a player has tilted the device vertically (along the Y), I've so far found this to work pretty well:
-- Store reference position which to measure tilt from.
local _, ay, az = playdate.readAccelerometer()
local start_v = geometry.vector2D.new(ay, az)
-- Elsewhere, measure angle off reference position
local _, ay, az = playdate.readAccelerometer()
local current_v = geometry.vectory2D.new(ay, az)
local tilt_angle = start_v:angleBetween(current_v)
I think that's it. Though I haven't tried it, it seems you'd be able to measure tilt along the X axis by replacing ay with ax (the first value off readAccelerometer that I'm ignoring in this example).
OK! Happy, um, accelerating?