TurboWarp / extensions

User-contributed unsandboxed extension gallery for TurboWarp
https://extensions.turbowarp.org/
MIT License
114 stars 233 forks source link

A sensor extension #1431

Open DNin01 opened 5 months ago

DNin01 commented 5 months ago

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.

DNin01 commented 5 months ago

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.

DNin01 commented 4 months ago

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

Xeltalliv commented 4 months ago

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