Skip to content

Add camera follow and shake, and gamepad input - #6

Merged
RohanFredriksson merged 1 commit into
masterfrom
claude/gameplay-api-batch5
Oct 16, 2026
Merged

RohanFredriksson merged 1 commit into
masterfrom
claude/gameplay-api-batch5

Conversation

@RohanFredriksson

Copy link
Copy Markdown
Owner

Batch 4 of ROADMAP.md.

  • CameraFollow component: follows its own entity, or another by id, with an offset, exponential smoothing that doesn't depend on frame rate, a dead zone, and bounds that keep the view inside them (or centre it when it doesn't fit). It snaps on start and when the target changes, and is serialised. The logic is in apply(camera, target, dt), so it is tested without a window.
  • Camera::shake(intensity, duration) moves the view by a random offset that fades out quadratically, keeping the stronger of overlapping shakes. Only getView changes, so the camera's position, following and mouse world coordinates are unaffected. A paused scene holds the offset.
  • GamepadListener: polled each frame after glfwPollEvents. Buttons have down, begin down and end down (compared with the previous poll, and a disconnect releases everything). Axes have a configurable dead zone, applied radially to sticks. Stick y points up, and triggers go from 0 to 1. setState lets tests and tools fake a pad.
  • Console commands shake and gamepads.
  • The demo shakes the camera on hard impacts, and a gamepad's left stick pans and A drops a box.

Tests: new unit test test_camera for shake, follow (snap, frame-rate independent smoothing, dead zone, offset, bounds, json) and gamepad state, and engine test test_camera_engine for following through the scene, changing and losing the target, shake from the console, and per-frame polling.

Claude-Session: https://claude.ai/code/session_015cNAkNqoDWA5gFReD1AsqV

Batch 4 of ROADMAP.md.

- CameraFollow component: follows its own entity, or another by id, with
  an offset, exponential smoothing that doesn't depend on frame rate, a
  dead zone, and bounds that keep the view inside them (or centre it when
  it doesn't fit). It snaps on start and when the target changes, and is
  serialised. The logic is in apply(camera, target, dt), so it is tested
  without a window.
- Camera::shake(intensity, duration) moves the view by a random offset
  that fades out quadratically, keeping the stronger of overlapping
  shakes. Only getView changes, so the camera's position, following and
  mouse world coordinates are unaffected. A paused scene holds the offset.
- GamepadListener: polled each frame after glfwPollEvents. Buttons have
  down, begin down and end down (compared with the previous poll, and a
  disconnect releases everything). Axes have a configurable dead zone,
  applied radially to sticks. Stick y points up, and triggers go from 0
  to 1. setState lets tests and tools fake a pad.
- Console commands shake and gamepads.
- The demo shakes the camera on hard impacts, and a gamepad's left stick
  pans and A drops a box.

Tests: new unit test test_camera for shake, follow (snap, frame-rate
independent smoothing, dead zone, offset, bounds, json) and gamepad state,
and engine test test_camera_engine for following through the scene,
changing and losing the target, shake from the console, and per-frame
polling.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015cNAkNqoDWA5gFReD1AsqV
@RohanFredriksson
RohanFredriksson merged commit 94aad75 into master Oct 16, 2026
8 checks passed
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