forked from scratchfoundation/scratch-vm
-
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add tilt blocks to MicroBit More extension (Issue #20 Task 3) #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a new gesture option "TILTED" that triggers when any of the tilt events (TILT_UP, TILT_DOWN, TILT_LEFT, TILT_RIGHT) occur. This matches the microbit extension's "(どれかの向き▼)に傾いたとき" behavior. Implementation details: - Add TILTED menu item to GESTURES_MENU - Add state tracking variables for tilt events - Add TILTED handling in whenGesture method with gap detection logic - Add Japanese translations for the new menu item Refs smalruby/smalruby3-develop#20 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added a new boolean block "[DIRECTION] に傾いた" that detects tilt state: Implementation: - Added TILT_DIRECTION_MENU with options: ANY, UP, DOWN, LEFT, RIGHT - Added isTilted method that returns true if tilted within 5 frames - Uses gesture event timestamps for tilt detection - Matches microbit extension pattern for user migration Japanese translations: - Block: "[DIRECTION] に傾いた" / "[DIRECTION] にかたむいた" - Menu items: どれかの向き, 上, 下, 左, 右 Related to: smalruby/smalruby3-develop#20 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added a new reporter block "[DIRECTION] 方向の傾き" that returns tilt angle: Implementation: - Added TILT_ANGLE_DIRECTION_MENU with options: FRONT, BACK, LEFT, RIGHT - Added getTiltAngle method using pitch/roll values: - FRONT → pitch (forward tilt angle) - BACK → -pitch (backward tilt angle) - LEFT → roll (left tilt angle) - RIGHT → -roll (right tilt angle) - Matches microbit extension pattern for user migration Japanese translations: - Block: "[DIRECTION] 方向の傾き" / "[DIRECTION] ほうこうのかたむき" - Menu items: 前, 後ろ, 左, 右 / まえ, うしろ, ひだり, みぎ Related to: smalruby/smalruby3-develop#20 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- FRONT vertical now returns -90 as expected by user - Nose-up is now positive for pitch, matching description - Clockwise tilt is now positive for roll, matching description - Corrected inverted behavior in getTiltAngle, getPitch, and getRoll blocks Issue #20
…n logic - Modified getTiltAngle to return positive values when tilted in the specified direction - Re-implemented isTilted to use tilt angle value (>= 15 degrees) instead of gesture events - This matches the behavior of the standard micro:bit extension and fixes user-reported issues Issue #20
- Updated tiltDirectionMenu and GESTURES_MENU labels (English and Japanese) - Changed 'up' to 'front' and 'down' to 'back' to match physical orientation - Fixed 'titl' typo in English default strings Issue #20
…ate system" This reverts commit 477c222.
- Swapped MbitMoreGestureID mapping for 1 and 2 to correct inverted tilt front/back detection - Updated Japanese (ja/ja-Hira) translations for tilt gestures from 'へ傾いた' to 'に傾いた' - Confirmed 'TILTED' (any) gesture correctly filters only tilt directions Issue #20
- Implemented whenPinConnected hat block (Standard micro:bit compatibility) - Reuses whenTouchEvent logic with fixed 'DOWN' (touched) event - Added touchPinIDMenu restricting pins to 0, 1, and 2 - Added translations for the new block in ja, ja-Hira, and de Issue #20
- Fixed broken JSDoc comment that caused whenTouchEvent to be incorrectly parsed - Resolves 'this.whenTouchEvent is not a function' error Issue #20
- Remove gap and timeout thresholds for TILTED gesture - Make TILTED gesture a simple proxy for TILT_UP, TILT_DOWN, TILT_LEFT, and TILT_RIGHT events - Remove unused tilt tracking properties from constructor Co-Authored-By: Gemini <noreply@google.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Added new tilt-related blocks to MicroBit More extension to match the original microbit extension:
Implementation Details
Task 3B: whenTilted event block
Task 3C: isTilted boolean block
Task 3D: getTiltAngle reporter block
Japanese Translations
All blocks and menu items have Japanese translations for both ja and ja-Hira locales.
Test Coverage
npm run lintpassesnpm run buildvia smalruby3-gui succeedsRelated
npm update scratch-vmto include these changes🤖 Generated with Claude Code