In 1981, Konami and Sega released Frogger, an arcade phenomenon that became one of the most celebrated video games in computing history.
To successfully guide a frog across a busy multi-lane highway and treacherous raging river into home lily pads, players intuitively solve rich physics and math problems: modular arithmetic of cyclic traffic flows and relative velocity in moving reference frames!
1. Cyclic Traffic Waves & Modular Arithmetic
Each highway lane acts as a one-dimensional periodic wave train. Vehicles of length $L$ travel at constant velocity $v$, wrapping cyclically across screen width $W = 600\text{ px}$:
$$x(t) = (x_0 + v t) \pmod W$$
The temporal period $T$ between passing vehicles is given by:
$$T = \frac{\Delta x}{|v|}$$
By synchronizing frog hops with these periodic intervals, you can hop precisely through oncoming gaps without colliding!
2. Relative Velocity & Reference Frames on River Logs
Once you reach the river, the water current moves logs horizontally. When our frog lands on a floating log moving at velocity $\vec{v}_{\text{log}}$ relative to the ground, the frog's velocity relative to the riverbank follows Galileo's classical velocity addition:
$$\vec{v}_{\text{frog, ground}} = \vec{v}_{\text{frog, log}} + \vec{v}_{\text{log, ground}}$$
While resting on the log ($\vec{v}_{\text{frog, log}} = 0$), the current carries the frog downstream:
$$\Delta x = v_{\text{log}} \cdot \Delta t$$
To reach an open lily pad cove at the far bank, you must calculate the drift time $\Delta t$ needed for the log to carry you directly in line with the target slot!
Move the mouse over a dotted box for more information.
Live Telemetry HUD: Displays current Score, Lives remaining, Row index, and Goals reached.
Relative Velocity Indicator: When resting on floating logs, notice how the log's drift velocity directly transfers to the frog's coordinate.
Interactive D-Pad & Keyboard Controls: You can also control the frog manually using the arrow keys or on-screen directional buttons!
Full Retro Sound Synthesis: Web Audio procedural sound effects for hopping, scoring, water submersion, and victory chimes.
Now you try. Can you hop across the highway to the median sidewalk, or try frogger_game(2) to ride river logs?
Type your code here:
See your results here:
Share your code
Show a friend, family member, or teacher what you've done!
Here is a share link to your code:
Need a hint?
💡 What now?
The code has ???? for the number of forward hops. Replace ???? with 3, then click Run Code!
1. In Stage #1, the frog starts at Row 9. The first hop advances to Row 8 (Lane 1).
2. After waiting 0.8 seconds, the oncoming traffic in Lane 2 clears.
3. Hopping 3 more times advances through Row 7, Row 6, and Row 5 to reach Row 4 (the safe median sidewalk)!
4. Challenge: Try frogger_game(2) to ride floating logs and navigate relative velocity, or frogger_game(4) for the full highway and river crossing!