feat(coaster): add WASD/arrow key panning to match iso-city controls#361
feat(coaster): add WASD/arrow key panning to match iso-city controls#361rbouschery wants to merge 2 commits intoamilich:mainfrom
Conversation
Harmonizes camera controls between iso city and coaster games. Added keyboard-based panning with the same speed and bounds logic.
|
Your pull request is now ready for review with Assert. Stop waiting for your code to break. Ship with confidence using Assert. |
|
@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]); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| cancelAnimationFrame(animationFrameId); | ||
| pressed.clear(); | ||
| }; | ||
| }, [zoom, canvasSize, latestStateRef]); |
There was a problem hiding this comment.
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.


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
CoasterGridusing WASD/arrow keys, matching the iso-city control feel/speed via sharedKEY_PAN_SPEEDand clamping movement to the same map bounds.Also updates
CanvasIsometricGridto clear the pressed-key state onwindow.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.