
<canvas> (CanvasRenderingContext2D), inline SVGsAudioContext)App.tsx): Acts as the central game controller. It holds the core state (currentWPM, level, phase, combo) and coordinates transitions between game phases (ready, playing, escaping, levelComplete).requestAnimationFrame loops via useRef. React is only used to mount the canvas and pass down high-level game state (like speed or level).sessionStorage and localStorage, ensuring data survives page reloads without requiring a backend database (until the player submits to the global leaderboard).WordDisplay.tsx)keydown events (which fail on mobile software keyboards), the game forces focus onto a visually hidden <input type="text">. This tricks the browser into handling autocorrect, mobile keyboards, and language inputs natively.typedCount index, providing instant, sub-millisecond visual feedback.StarField.tsx)ctx.createRadialGradient, ctx.createLinearGradient, and trigonometric functions (Math.sin, Math.cos), the game draws complex celestial bodies. For example, Level 6 (Jupiter) is drawn using dozens of overlapping, slightly wavy bezier curves and gradients to simulate gas storms.0, 1, 2). During gameplay, the player's WPM is converted into a power multiplier, which accelerates the Y-axis translation of the stars, creating a hyper-speed parallax effect.AudioEngine.tsx).mp3 or .wav files, the game generates all sound effects and music on the fly using the browser's native Web Audio API.peaking filter for the metallic echo.requestAnimationFrame/setTimeout lookahead scheduler to queue notes. As the player's level increases, the engine dynamically alters the BPM, adds new instruments (sub-bass, hi-hats, arpeggios), and opens low-pass filters, resulting in a soundtrack that physically intensifies as the game gets harder.sessionAnalytics.ts & AnalyticsModal.tsx)setInterval loop records the player's WPM every 200ms.recharts, this snapshot array is fed into an <AreaChart> to show the player's typing speed over the course of a level. Bar charts and Pie charts break down peak performance and accuracy metrics.leaderboard.ts)orderBy("averageWPM", "desc").averageWPM greater than the player's, then iterates through them client-side to apply tie-breakers (like peakWPM). This keeps database operations cheap and fast.StarField, Rocket, and SubShips components use useRef to hold animation values and mutate the DOM or Canvas directly inside a requestAnimationFrame loop, bypassing the React reconciliation cycle entirely.Date.now() - startTime math will result in their WPM plummeting to zero when they resume.pausedAt and accumulates a totalPausedMs variable. When calculating WPM, the formula subtracts the total paused time from the elapsed time, ensuring the typing speed graph remains perfectly accurate.ensureCtx() callback. It waits for the very first keystroke (triggerClick), instantiates the AudioContext, and begins the background music loop concurrently with the typing sound.


Posted Mar 25, 2026
TypeVelocity is a React-based typing game where your WPM drives a rocket. Built with zero assets, it features procedural Canvas graphics and Web Audio synths.