All projects

Personal project

Dinosaur Game

My recreation of the Google Chrome Dinosaur Game, built in Python with the pygame library, including sound.

Python pygame
§ 01 - OVERVIEW

About

This is my version of the Google Chrome Dinosaur Game. It was created in Python with the pygame library.

§ 02 - THE GAME

About the Dinosaur Game

The Dinosaur Game is an infinite runner, where the goal is to run for as long as possible. Obstacles - cacti and birds - appear as you run and progressively get faster. The player can duck and jump to avoid them.

An example game.
An example game where the dinosaur tries to avoid the obstacles for as long as possible.
§ 03 - IMPLEMENTATION

My Version

All code is held in the DinosaurGame.py file. When the main() function is executed, all assets are loaded before the main game loop runs. During this time, the program checks if the data folder exists and if the score.txt file exists. If either does not exist, it will create the directory or file. The score.txt file is necessary to save the player's high score after the game is closed.

For each group of assets - dinosaur, ground, obstacles, and clouds - there are functions to create, move, and delete them.

On startup, the very first game has a special animation at the beginning, to emulate what happens on the Google Chrome version.

How to Play

To run the game, first run the DinosaurGame.py file. To start the game press the w or Up Arrow keys.

  • w / Up Arrow - jump
  • s / Down Arrow - duck
The start animation of the game.
The animation that plays when you first run the game.
§ 04 - SOURCE

Want to try it yourself?

The full source is on GitHub, or browse the rest of what I've built.