Repository navigation
Add camera follow and shake, and gamepad input - #5
Merged
RohanFredriksson merged 1 commit intoOct 16, 2026
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch 4 of
ROADMAP.md. This is stacked on #4 (batch 3), so it targets that branch and the diff shows only batch 4. Merge #4 first, then change this PR's base tomaster.Changes
CameraFollowcomponent (components/camerafollow.hpp):setTarget).apply(camera, target, dt), so it is unit-tested without a window.Camera::shake(intensity, duration), plusstopShake,isShakingandgetShakeOffset.getViewchanges, sogetPosition,CameraFollowand mouse world coordinates aren't disturbed. A paused scene holds the offset.GamepadListener: polled each frame afterglfwPollEvents.setStatelets tests and tools fake a pad.shake <intensity> [duration]andgamepads.Testing
tests/test_camera.cppcovers:tests/test_camera_engine.cppcovers following through the scene, switching and losing the target, shake from the console, and that a faked pad is replaced by the next real poll.🤖 Generated with Claude Code
https://claude.ai/code/session_015cNAkNqoDWA5gFReD1AsqV
Generated by Claude Code