TurboWarp/extensions

A sensor extension

Opened this issue · 3 comments

Sometimes you want to make games or interactive elements that respond to input other than mouse, keyboard, or touch, and for this, it could be really cool to have an extension that can read various sensors of the device, such as the accelerometer or gyroscope.

We could implement anything that is offered by the Sensor APIs.

Sensing Plus has a block to get accelerometer/gyroscope data but it also has a bunch of other blocks that I don't necessarily want to have to import along. Plus, a dedicated extension would probably be programmed better as sensor access would be the whole point of it.

We could also use device orientation events, which are more widely supported.

Keep in mind that the behavior may differ between browsers.

Note that Safari for macOS supports these APIs since version 17, but Safari for iOS has supported them since version 4.2, released in 2010. On that note, seeing that people are probably going to be making mostly mobile games in TurboWarp that utilize these features, we may not even want a motion sensing extension to work on computers.

Some of you developers might like to try https://sensor-js.xyz/demo.html on your mobile devices to test out the features.

I made this https://github.com/Xeltalliv/extensions/blob/generic-sensors/extensions/Vadik1/generic-sensors.js over a year ago, but haven't submitted to any extension gallery