Skip to content

Add lightning gesture casting and improve movement#9

Merged
PJensen merged 2 commits intomasterfrom
codex/fix-wall-sticking-issue-and-add-lightning-spell-mechanic
Nov 7, 2025
Merged

Add lightning gesture casting and improve movement#9
PJensen merged 2 commits intomasterfrom
codex/fix-wall-sticking-issue-and-add-lightning-spell-mechanic

Conversation

@PJensen
Copy link
Owner

@PJensen PJensen commented Nov 7, 2025

Summary

  • add gesture capture support to the input manager and recognize a lightning "Z" stroke
  • trigger the lightning spell via gesture when learned and surface a glowing HUD hint
  • enrich bolt visual effects with light pulses along the arc and make wall sliding more forgiving

Testing

  • npm test (fails: requires /workspace/JSHack/src/lib/ecs-js/index.js)

Codex Task

Copilot AI review requested due to automatic review settings November 7, 2025 02:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (dirDot < SLIDE_DOT_THRESHOLD) {
if (dirDot < -SLIDE_DOT_THRESHOLD) {

Copilot uses AI. Check for mistakes.
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;
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
if (!force && last) {
const dx = pointer.sx - last.x;
const dy = pointer.sy - last.y;
if (Math.hypot(dx, dy) < 4) {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number 4 (pixel distance threshold for gesture point deduplication) should be extracted as a named constant like MIN_GESTURE_POINT_DISTANCE for clarity.

Copilot uses AI. Check for mistakes.
@PJensen PJensen merged commit 52f8107 into master Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants