Skip to content
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

feat(camera): add mouse-driven panning #13

Merged
merged 3 commits into from
Jul 20, 2024

Conversation

ShenMian
Copy link
Contributor

Move the viewport when the mouse is close to the edge of the window.
Allows players to play the game using only a mouse.

Known defects: When the player attempts to select a tool through the UI it causes the viewport to move because the toolbar is at the edge of the window.

@ShenMian ShenMian force-pushed the feature/cursor_move_viewport branch from ea5e901 to 8c897b7 Compare July 20, 2024 02:04
Enable panning of the camera based on
the cursor position relative to the viewport.
@ShenMian ShenMian force-pushed the feature/cursor_move_viewport branch from 8c897b7 to 4e230a8 Compare July 20, 2024 02:07
src/camera.rs Outdated Show resolved Hide resolved
@rparrett
Copy link
Owner

Cool!

This is something I wanted to do but that got cut for time during the Jam.

Known defects: When the player attempts to select a tool through the UI it causes the viewport to move because the toolbar is at the edge of the window.

My initial thought is that we could wrap the toolbar in a NodeBundle with Interaction (to cover the gaps between buttons) and check for any node with Interaction::Hovered when scrolling. We could look at doing this in a followup though, it doesn't seem critical.

Replace the custom map_range function with the remap function from the
glam crate to simplify the code.
@ShenMian ShenMian force-pushed the feature/cursor_move_viewport branch from d244718 to 2c34285 Compare July 20, 2024 15:04
src/camera.rs Outdated Show resolved Hide resolved
@rparrett rparrett merged commit 1f4b6b2 into rparrett:main Jul 20, 2024
3 checks passed
@rparrett
Copy link
Owner

Thanks!

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.

2 participants