Add ghost race: replay your best run - #4
Merged
Conversation
- GhostRecorder decimates player position to ~10 Hz tracks (capped 6000 pts) - Track persists per level when the run sets a new best score - Daily Rex tracks are date-stamped and only replay for the same daily seed - Translucent ghost Rex with a small tag races alongside the player - G key / menu button toggles the ghost (persisted, default on) - 12 new unit tests + 2 integration tests (123 total, all passing)
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.
What
A local "race yourself" mode: the game records your position each frame (decimated to ~10 Hz), and when a run beats your stored best score for a level, the track is persisted. In later runs a translucent ghost Rex replays that best run alongside you.
Details
src/ghost.ts(new) —GhostRecorder(trailing-sample decimation, 6000-pt cap, discards runs under 4 samples) andGhostPlayer(monotonic index walk + linear interpolation, clamped past the track's end, facing from sample direction).src/store.ts—getGhostTrack/saveGhostTrack(tinyrex_ghost_0..2,tinyrex_ghost_daily),getGhostEnabled/setGhostEnabled(default on). Daily tracks are date-stamped withdailySeed()and only replay for the seed they were recorded on.src/game.ts— records during play, saves on new best (hand-built + daily), draws the ghost at 40% alpha with a small "GHOST" tag before the player,Gkey + menu toggle button, CONTROLS row updated.Validation (local — CI is failing for pre-existing unrelated reasons)
npm run typecheck✓npm test— 123/123 ✓npm run build✓ (single file, ~106 kB / 33 kB gzip)npm run lint✓Gkey toggle persists, no ghost when off, zero page errors ✓Supersedes nothing; stacks on #3 (Daily Rex).