Add relative cursor aiming mode #74

Merged
cammymoop merged 2 commits from feature/relative-cursor-aiming into master 2026-03-05 11:17:02 -06:00
Collaborator

Summary

  • Mouse is captured during gameplay and released when the player dies
  • Mouse motion accumulates into cursor_offset (world-space vector from player to cursor); player movement leaves it unchanged, so aim direction stays constant while moving
  • Cursor sprite lives in a CursorLayer (CanvasLayer layer=10) in the gameplay scene; projected from player screen pos toward virtual world pos, clamped to screen edge when out of bounds
  • cursor_offset clamped to screen diagonal in world units so the cursor can reach any screen point
  • On round start cursor warps to 80px right of the player
  • Falls back to get_global_mouse_position() if no cursor node is present

Test plan

  • Headless run exits clean with no errors
  • gdlint passes on all new/modified files
  • Moving player without moving mouse keeps aim direction constant
  • Moving mouse rotates aim
  • Cursor sprite clamps to screen edge when aiming near/past screen boundary
  • Mouse releases when player dies (shop opens normally)
  • Mouse re-captures when a new round starts
## Summary - Mouse is captured during gameplay and released when the player dies - Mouse motion accumulates into `cursor_offset` (world-space vector from player to cursor); player movement leaves it unchanged, so aim direction stays constant while moving - Cursor sprite lives in a `CursorLayer` (CanvasLayer layer=10) in the gameplay scene; projected from player screen pos toward virtual world pos, clamped to screen edge when out of bounds - `cursor_offset` clamped to screen diagonal in world units so the cursor can reach any screen point - On round start cursor warps to 80px right of the player - Falls back to `get_global_mouse_position()` if no cursor node is present ## Test plan - [x] Headless run exits clean with no errors - [x] gdlint passes on all new/modified files - [ ] Moving player without moving mouse keeps aim direction constant - [ ] Moving mouse rotates aim - [ ] Cursor sprite clamps to screen edge when aiming near/past screen boundary - [ ] Mouse releases when player dies (shop opens normally) - [ ] Mouse re-captures when a new round starts
Replaces free-mouse aiming with a node-bound virtual cursor:
- Mouse is captured (MOUSE_MODE_CAPTURED) during gameplay and released
  when the player dies
- Mouse motion deltas are converted to world-space and accumulated in
  `cursor_offset` (world-space vector from player to cursor)
- Player movement leaves `cursor_offset` unchanged, keeping aim
  direction constant while moving; only mouse motion rotates aim
- On round start the cursor warps to 80px right of the player
- Cursor sprite lives in a CanvasLayer (layer=10) in the gameplay
  scene; its screen position is projected from the player's screen pos
  toward the virtual world pos and clamped to the screen edge when the
  virtual pos is out of bounds
- cursor_offset is clamped to the screen diagonal in world units so the
  cursor can reach any screen point but no further

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cursor_offset is viewport-space (screen pixels from player's screen
position), not world-space. With a following camera the two are
related by the zoom factor, which is not constant as the arena resizes.

Changes:
- cursor_offset accumulates mouse deltas directly (event.relative,
  no zoom division); max clamp is screen diagonal in pixels
- Warp on gameplay start: offset from screen center toward real mouse
  position, clamped to configurable spawn_distance (screen pixels)
- Warp on gameplay end: real mouse placed at screen_center +
  cursor_offset so it lands where the virtual cursor was
- get_world_pos() replaced with get_viewport_pos()
- Aim angle in player computed as cursor_offset.angle() (viewport
  space); fallback uses get_mouse_position() minus player screen pos

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cammymoop merged commit 0721225e48 into master 2026-03-05 11:17:02 -06:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cammymoop/semi-vibed-game!74
No description provided.