Add option to control micro:bit accelerometer with mouse #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly, thanks for making this, it's been a huge help in past workshops!
I have a workshop that gets people to build a snake game on micro:bit using the accelerometer. If they tilt the device forward, then the snake will move up the screen; if they tilt it to the left then the snake will move in a leftwards direction.
While this code can be simulated with this repository, it can be a bit inconvenient to have to adjust each accelerometer axis separately to make the snake move. This PR adds in the ability to change the accelerometer X and Y according to the mouse position.
I've added a checkbox to the accelerometer tab that allows this to be turned on and off since it would be surprising behaviour without explicitly requesting it. When the checkbox is ticked, the user can move the mouse within the
#microbit
element and the accelerometer values will change. In the snake example, it looks like the snake is trying to follow the mouse, which feels intuitive.I tried to add animations which you can test out in the mouse-accel-anim branch but I didn't like how they turned out. They made the screen more difficult to see, and it was hard to differentiate left from right and up from down.
If you want to test this code with the snake program, it's available in ears-edi/microbit-snake.
Let me know what you think!