A faithful recreation of the classic Chrome offline dinosaur game built entirely with Java Swing. Run, jump, and duck your way through an endless desert with smooth 60 fps gameplay, a parallax day/night cycle, and progressively increasing difficulty.
Most browser-based Dino clones rely on JavaScript or game engines. This one is built purely in Java with no external libraries โ a clean demonstration of object-oriented design, Swing rendering, and real-time game-loop architecture using only the standard JDK.
- Jump & Duck: Classic T-Rex controls โ Space/โ to jump, โ to duck
- Collision Detection: Pixel-accurate hitbox intersection for obstacles and the dino
- Progressive Speed: Game gradually accelerates every 200 score points, capped at 16 px/tick
- Automatic toggle: Scene switches between day and night every 700 score points
- Parallax clouds: Clouds scroll at 1/3 game speed for a depth illusion
- Adaptive colours: Sky, ground, text, and HUD all shift palette with the cycle
- Live score: Increments every game tick in a zero-padded 5-digit display
- Session high score: Best score preserved in memory for the session lifetime
- Speed readout: Current scroll speed shown in the top-left corner
- Day/Night badge: Emoji badge updates alongside the cycle toggle
- Cacti variants: Single, double, and triple cactus clusters spawned randomly
- Pterodactyls: Flying obstacles at varying heights for mid-air challenges
- Randomised gaps: Spacing between obstacles scales with game speed
- Java 8+ โ Core language; no third-party dependencies required
- Java Swing / AWT โ Rendering, window management, and input handling
- javax.swing.Timer โ Drives the 60 fps (~16 ms) game loop
- java.awt.Graphics2D โ Anti-aliased 2D rendering with gradient fills
- JDK 8 or higher
- Any Java IDE (IntelliJ IDEA, Eclipse, VS Code with Java extension) or a terminal
# Check Java version (should be 8+)
java -version
# Check compiler
javac -versionDon't want to build from source? Just download and run the installer.
| Platform | Download | Notes |
|---|---|---|
| ๐ฅ๏ธ Windows (64-bit) | DinoGame-1.0.0.msi | No Java required โ JRE is bundled |
git clone https://github.com/AnkeshGG/DinoGame.git
cd DinoGamejavac -d out src/*.javajava -cp out DinoGameIntelliJ IDEA: Open the project, right-click
DinoGame.javaโ Run 'DinoGame.main()'
| Key | Action |
|---|---|
Space / โ |
Jump (also starts / restarts the game) |
โ |
Duck (hold to crouch, release to stand) |
Enter |
Restart after Game Over |
DinoGame/
โโโ src/
โ โโโ DinoGame.java # Main panel, game loop, rendering, input
โ โโโ Dino.java # Player character: physics, animation, hitbox
โ โโโ ObstacleGenerator.java # Spawns, updates, and draws obstacles
โ โโโ Cloud.java # Decorative parallax background clouds
โ โโโ GameState.java # Enum: IDLE | RUNNING | GAME_OVER
โโโ assets/
โ โโโ DinoGame_Preview.gif # Gameplay demo clip
โโโ .gitignore
โโโ README.md
The game follows a simple component-based architecture driven by a single Swing Timer:
DinoGameโ Central hub: owns the game loop (actionPerformed), manages all entities, handles rendering back-to-front, and processes keyboard input.Dinoโ Self-contained player entity with jump physics (gravity + velocity), duck state, leg animation, and a shrinkable hitbox.ObstacleGeneratorโ Stateless spawner that maintains a list of activeObstacleobjects; each obstacle knows its own type, position, and how to draw itself.Cloudโ Lightweight value object; scrolls left at reduced speed and is recycled when off-screen.GameStateโ Three-value enum (IDLE,RUNNING,GAME_OVER) that gates all logic branches cleanly.
Automated unit tests are planned for a future release. Current validation is done through manual playtesting across all three game states and both day/night modes.
- Add sound effects (jump, game over, milestone)
- Persist high score to a local file across sessions
- Add a settings panel (volume, key remapping)
- Mobile-style touch/click controls
- Difficulty presets (Easy / Normal / Hard)
You're welcome to contribute to this open-source project!
- Fork the repo
- Create a branch:
git checkout -b feature/newFeature - Commit your changes
- Push:
git push origin feature/newFeature - Submit a pull request
- Follow standard Java code conventions
- Keep all rendering logic inside the relevant class's
draw()method - Test across both day and night modes before submitting PRs
This project is licensed under the MIT License โ see the LICENSE file for details.
Ankesh Kumar โ Java Developer & Game Enthusiast
I built this project to deepen my understanding of real-time rendering and game-loop design using nothing but the standard Java library โ no engines, no frameworks, just pure Swing.
- ๐ GitHub: @AnkeshGG
- ๐ผ LinkedIn: Ankesh Kumar
- ๐ Medium: ankeshGG
- Chrome Dino โ The original game by Google that inspired this recreation
- Java Swing Team โ For a surprisingly capable 2D rendering toolkit
- Open Source Community โ For countless references and inspiration
๐ข Actively maintained
- Version: 1.0.0
- Last Updated: February 2026
- Latest Release: v1.0.0
- Stars: โญ Give this project a star if you enjoyed it!
- Issues: Tracked via GitHub Issues
An endless runner with no finish line โ just you, a dinosaur, and an ever-faster desert. Jump over cacti, dodge pterodactyls, and push through the night to set a new personal best.
โฌ๏ธ Download Installer | ๐ฅ Clone & Play | ๐ฎ Controls | ๐ค Contribute
ยฉ 2026 Ankesh Kumar.
