Skip to content

feat(coaster): add WASD/arrow key panning to match iso-city controls#361

Open
rbouschery wants to merge 2 commits intoamilich:mainfrom
rbouschery:rb/movement-iso-coaster
Open

feat(coaster): add WASD/arrow key panning to match iso-city controls#361
rbouschery wants to merge 2 commits intoamilich:mainfrom
rbouschery:rb/movement-iso-coaster

Conversation

@rbouschery
Copy link

@rbouschery rbouschery commented Jan 30, 2026

Harmonizes camera controls between iso-city and iso-coaster.

Added keyboard-based panning with the same speed and bounds logic.


Note

Low Risk
Low risk UI/input change limited to viewport movement; main risk is minor regressions in key handling or panning bounds/feel.

Overview
Adds keyboard-based camera panning to CoasterGrid using WASD/arrow keys, matching the iso-city control feel/speed via shared KEY_PAN_SPEED and clamping movement to the same map bounds.

Also updates CanvasIsometricGrid to clear the pressed-key state on window.blur, preventing “stuck key” panning when the tab/window loses focus.

Written by Cursor Bugbot for commit b00fb56. This will update automatically on new commits. Configure here.

Cursor Bugbot found 1 potential issue for commit b00fb56

Harmonizes camera controls between iso city and coaster games.
Added keyboard-based panning with the same speed and bounds logic.
@assert-app
Copy link

assert-app bot commented Jan 30, 2026

Your pull request is now ready for review with Assert.

Open Review →


Stop waiting for your code to break. Ship with confidence using Assert.

@vercel
Copy link
Contributor

vercel bot commented Jan 30, 2026

@rbouschery is attempting to deploy a commit to the andrew-4640's projects Team on Vercel.

A member of the Team first needs to authorize it.

cancelAnimationFrame(animationFrameId);
pressed.clear();
};
}, [zoom, canvasSize, latestStateRef]);
Copy link

Choose a reason for hiding this comment

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

Keyboard panning stops when zoom level changes

Medium Severity · Logic Bug

When zoom or canvasSize changes (e.g., user scrolls to zoom), the keyboard panning useEffect re-runs due to these values being in its dependency array. The cleanup function calls pressed.clear() on keysPressedRef.current, which erases all currently-tracked key presses. If a user is holding a pan key (like 'W') while zooming with the scroll wheel, panning stops abruptly and they must release and re-press the key to continue.

Fix in Cursor Fix in Web

Copy link
Author

Choose a reason for hiding this comment

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

I have manually tested this and cannot reproduce the behavior mentioned by Bugbot during gameplay. It acts as it is supposed to enabling zooming and moving at the same time.

…t): import from const instead of redefining variable
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

cancelAnimationFrame(animationFrameId);
pressed.clear();
};
}, [zoom, canvasSize, latestStateRef]);
Copy link

Choose a reason for hiding this comment

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

Duplicated keyboard panning logic across two components

Medium Severity · Code Quality

The keyboard panning useEffect (~75 lines) is a near-identical copy of the existing implementation in CanvasIsometricGrid.tsx (lines 604-678). Both contain the same isTypingTarget helper, identical event handlers, animation frame loop, key mappings, and bounds calculation logic. This logic should be extracted into a shared custom hook like useKeyboardPanning.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant