feat: scream when hedgehog is harshly thrown#2438
Closed
fercgomes wants to merge 1 commit into
Closed
Conversation
When hedgehog mode is enabled and the user grabs the hog and flings it sharply upward, play the Wilhelm scream. Detection is purely renderer-side via the hedgehog-mode package's public API: on every pointerup we defer one animation frame so Matter.js has applied the post-release velocity, then inspect each hedgehog's rigidBody.velocity. If a hog is moving up faster than the autonomous jump speed (y < -25, speed > 25), we play the scream at the user's completionVolume. The wilhelm.mp3 asset already shipped as a selectable task-completion sound; this just wires it to throw releases as well via a new one-shot playSoundUrl helper that doesn't interfere with the completion-sound audio chain. Generated-By: PostHog Code Task-Id: a92f24e3-30a1-4e8d-a6e8-5fb508ef9993
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.
Summary
When hedgehog mode is enabled and the user grabs the hog and flings it sharply upward, play the Wilhelm scream.
@posthog/hedgehog-modepackage's public API: on everypointerupwe defer one animation frame so Matter.js has applied the post-release velocity, then inspect each hedgehog'srigidBody.velocity. If a hog is moving upward faster than the autonomous jump speed (y < -25ANDspeed > 25), we play the scream at the user'scompletionVolume.wilhelm.mp3asset already shipped as a selectable task-completion sound; this just wires it to throw releases as well via a new one-shotplaySoundUrlhelper that doesn't interfere with the completion-sound audio chain.Thresholds are an initial guess (
25in Matter.js units, comfortably above the autonomousjump()velocity of15). Easy to tune.Test plan
pnpm --filter code typecheck(already green locally)completionVolume = 0→ throws are silentpointerups