Download on the App StoreGet it on Google Play

Wiki

Chrome Dino Source Code

Inside the Open-Source Code Behind Google's T-Rex Runner

Updated WikiFirst published
Chrome Dino Source Code
The Jumping Dino gameplayiOS + Android

The Chrome Dino game is part of the open-source Chromium project, so its current implementation can be inspected directly in Google's source repository. As of July 2026, the game lives in components/neterror/resources/dino_game/. The main Runner controller is in offline.ts, while scoring, the T-Rex, obstacles, the horizon, sprites, game state, and sound are split into focused TypeScript modules. Older explanations that describe one current offline.js file are referring to a previous Chromium architecture. The game still uses the HTML Canvas API and browser timing primitives rather than a third-party game engine. Runner coordinates input and state, Trex owns jump and duck behavior, Obstacle and Horizon manage the moving world, and DistanceMeter converts distance into the displayed score. The current distance_meter.ts also proves that the display expands from five to six digits after 99,999. For developers, the code is a useful compact example of modular TypeScript, configuration-driven gameplay, accessibility support, sprite animation, collision detection, and a requestAnimationFrame loop.

01

Key Classes and Architecture

The current Chrome Dino source is organized into focused modules: - offline.ts / Runner: coordinates the game loop, input, speed, score state, pause/restart behavior, and accessibility.

  • trex.ts: manages jump physics, ducking, animation states, and collision boxes.
  • obstacle.ts: defines cactus and pterodactyl movement and spawning behavior.
  • horizon.ts and related files: draw the ground, clouds, moon, night mode, and scrolling world.
  • distance_meter.ts: converts distance to score, draws the high score, flashes achievements, and expands the display after the initial five digits.
  • game_config.ts and sprite definition files: keep speeds, gaps, modes, and asset positions configuration-driven. This modular TypeScript layout replaced the older single-file JavaScript structure.
02

How the Game Loop Works

The game uses a standard requestAnimationFrame loop. Each frame, the Runner.update method: 1. Calculates the time elapsed since the last frame 2. Updates the game speed based on elapsed distance 3. Moves all obstacles by their current speed 4. Checks for collisions between the T-Rex and any obstacle 5. Updates the score and distance meter 6. Clears the canvas and redraws all elements 7. Schedules the next frame If a collision is detected, the game enters a 'crashed' state, plays a brief animation, and waits for the player to press spacebar to restart. The entire game runs at a target of 60 frames per second, with delta-time compensation to ensure consistent physics on both fast and slow displays.

03

Learning From the Codebase

The current source demonstrates several useful engineering ideas in a real production feature: - Modular responsibility: runner, character, world, score, state, and assets are separate TypeScript modules.

  • Event-driven input: keyboard, pointer, touch, visibility, focus, and gamepad events feed the same game state.
  • Explicit state: waiting, running, jumping, ducking, paused, and crashed behavior is represented directly.
  • Configuration-driven gameplay: acceleration, maximum speed, obstacle gaps, mobile coefficients, and alternate modes are data-driven.
  • Accessibility: live-region messages, labels, slowdown controls, and input alternatives are part of the current implementation.
  • Frame-rate-aware timing: requestAnimationFrame and elapsed time keep movement consistent. Read the current Chromium files rather than copied tutorials built around the retired offline.js layout.
Topicschrome dinosource codejavascriptchromiumopen source

Play while you read

Play now or get the full game

Play the browser runner, or get the mobile app with Campaign, Infinite mode, dinosaur progression, and AI ghost races.

Sources & References

Last verified:

LEVEL UP

Love the Classic? Meet the Evolution.

The Jumping Dino takes everything you love about the Chrome dino game and turns it into a full adventure.

Campaign + Infinite + Multiplayer
Rescue eggs across 5 eras
Hatch dinos, build the Sanctuary
iOS & Android; 2 offline modes

3M+

Downloads

4.3★

Google Play rating

9.28K

Reviews

Love the Classic? Meet the Evolution.
Download on the App StoreGet it on Google Play

Answers

Frequently Asked Questions

Yes. Chrome Dino is part of the Chromium open-source project. The current implementation is in components/neterror/resources/dino_game, with the main runner in offline.ts and separate TypeScript modules for the distance meter, T-Rex, obstacles, horizon, and other systems.

The current Chromium implementation is written in TypeScript and compiled for Chrome. It uses browser APIs and HTML Canvas rather than a third-party game engine. Older Chromium versions kept much of the logic in a single offline.js file.

You can view and fork the Chromium source code under its open-source license. You cannot modify the version running in your Chrome browser without building a custom version of Chromium. However, you can manipulate the running game via Chrome's JavaScript console.

The current code is a compact example of modular TypeScript, Canvas sprite animation, bounding-box collision detection, configuration-driven gameplay, accessibility hooks, and requestAnimationFrame timing without a third-party game engine.

Keep exploring

Related Pages