Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a lightning spell gesture recognition system that allows players to cast the lightning spell by drawing a "Z" shape with their pointer device. The implementation includes gesture recognition logic, UI feedback, visual effects enhancements, and adjustments to the movement system's sliding behavior.
- Implements a "Z" gesture recognizer with quality scoring for the lightning spell
- Adds UI hints to teach players the gesture and provide feedback when casting
- Enhances lightning visual effects with multiple light pulses along the bolt path
- Adjusts movement system collision sliding threshold for improved feel
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/rules/systems/movementSystem.js | Changes collision sliding threshold from checking negative dot product to a more permissive constant value |
| src/main/world/worldEvents.js | Adds multiple light pulses along lightning bolt path and triggers gesture hint on spell learn |
| src/main/ui/setupUIEventListeners.js | Adds event listener for spell gestures that casts lightning and shows UI feedback |
| src/display/ui/overlay.js | Creates spell gesture hint overlay with animated "Z" glyph and caption |
| src/display/input/gestureRecognizers.js | New file implementing lightning "Z" gesture recognition with geometric validation |
| src/display/input/InputManager.js | Refactors pointer handling to track gesture points and detect spell gestures |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const ny = sweep.normal.y / nLen; | ||
| const dirDot = dirx * nx + diry * ny; | ||
| if (dirDot < -EPS) { | ||
| if (dirDot < SLIDE_DOT_THRESHOLD) { |
There was a problem hiding this comment.
The sliding condition is inverted. The original code dirDot < -EPS checked if the direction was moving into the wall (negative dot product). The new constant SLIDE_DOT_THRESHOLD = 0.35 allows sliding when moving away from or parallel to the wall (positive values up to 0.35), which is backwards. This will prevent sliding when the player should slide, breaking wall-sliding movement. The condition should likely be dirDot < -SLIDE_DOT_THRESHOLD to maintain the intended behavior while making the threshold more permissive.
| if (dirDot < SLIDE_DOT_THRESHOLD) { | |
| if (dirDot < -SLIDE_DOT_THRESHOLD) { |
| if (!this._gesturePoints || this._gesturePoints.length < 6) return; | ||
| const now = performance?.now ? performance.now() : Date.now(); | ||
| const duration = (now - this._gestureStartTime) / 1000; | ||
| if (!Number.isFinite(duration) || duration < 0.12) return; |
There was a problem hiding this comment.
Magic number 0.12 should be extracted as a named constant like MIN_GESTURE_DURATION for clarity and maintainability. This threshold determines the minimum time required to complete a valid gesture.
| if (!force && last) { | ||
| const dx = pointer.sx - last.x; | ||
| const dy = pointer.sy - last.y; | ||
| if (Math.hypot(dx, dy) < 4) { |
There was a problem hiding this comment.
Magic number 4 (pixel distance threshold for gesture point deduplication) should be extracted as a named constant like MIN_GESTURE_POINT_DISTANCE for clarity.
Summary
Testing
npm test(fails: requires /workspace/JSHack/src/lib/ecs-js/index.js)Codex Task