Skip to content

iammrranik/Car-Racing-PyGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— Car Racing Game (Python Midterm Project)


โœจ Status

๐Ÿšง Completed
๐Ÿง  Built with Python 3.14.3
๐ŸŽฎ Uses pygame-ce
๐ŸŽฏ Designed for Midterm Evaluation


๐ŸŽฎ Game Overview

This is a classic car racing game built for a Python midterm project. The player controls a car, avoids obstacles, and tries to achieve the highest score possible. The game features modular code, a clean UI, and persistent high scores.


๐Ÿ”ฅ Features

  • ๐Ÿงฉ Clean & Modular Code (OOP, separate modules for entities, utils, settings)
  • โšก Optimized Performance (uses efficient game loop and asset loading)
  • ๐Ÿ–ฅ๏ธ User-Friendly Interface (simple controls, clear visuals)
  • ๐Ÿ“Š High Score Tracking (CSV-based, persistent)
  • ๐ŸŽต Sound & Graphics (custom assets, background music, icons)
  • ๐Ÿ“ Well-Structured Project Architecture

๐Ÿ“Œ Tech Stack

  • Python 3.14.3
  • pygame-ce
  • Git & GitHub
  • VS Code

๐Ÿ—‚๏ธ Project Structure

โ”œโ”€โ”€ Main.py
โ”œโ”€โ”€ Game.py
โ”œโ”€โ”€ Settings.py
โ”œโ”€โ”€ Utils.py
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ Entities/
โ”‚   โ”œโ”€โ”€ Car.py
โ”‚   โ”œโ”€โ”€ CarObstacle.py
โ”‚   โ””โ”€โ”€ CarPlayer.py
โ”œโ”€โ”€ Db/
โ”‚   โ”œโ”€โ”€ FileLoader.py
โ”‚   โ”œโ”€โ”€ Paths.py
โ”‚   โ””โ”€โ”€ Hiscore.csv
โ”œโ”€โ”€ Assets/
โ”‚   โ”œโ”€โ”€ Background/
โ”‚   โ”‚   โ”œโ”€โ”€ Image/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ bg_game_over.png
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ bg_hiscore.png
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ bg_home.png
โ”‚   โ”‚   โ””โ”€โ”€ Sound/
โ”‚   โ”‚       โ”œโ”€โ”€ beep.ogg
โ”‚   โ”‚       โ”œโ”€โ”€ charmer.mp3
โ”‚   โ”‚       โ””โ”€โ”€ explosion.wav
โ”‚   โ”œโ”€โ”€ CarModels/
โ”‚   โ”‚   โ”œโ”€โ”€ bike.png
โ”‚   โ”‚   โ”œโ”€โ”€ bike2.png
โ”‚   โ”‚   โ”œโ”€โ”€ bmw.png
โ”‚   โ”‚   โ”œโ”€โ”€ bmw2.png
โ”‚   โ”‚   โ”œโ”€โ”€ bmw3.png
โ”‚   โ”‚   โ”œโ”€โ”€ camaro.png
โ”‚   โ”‚   โ”œโ”€โ”€ camaro2.png
โ”‚   โ”‚   โ”œโ”€โ”€ challenger2.png
โ”‚   โ”‚   โ”œโ”€โ”€ challenger3.png
โ”‚   โ”‚   โ”œโ”€โ”€ convertible.png
โ”‚   โ”‚   โ”œโ”€โ”€ dumptruck.png
โ”‚   โ”‚   โ”œโ”€โ”€ figo.png
โ”‚   โ”‚   โ”œโ”€โ”€ figo2.png
โ”‚   โ”‚   โ”œโ”€โ”€ gwagon.png
โ”‚   โ”‚   โ”œโ”€โ”€ gwagon2.png
โ”‚   โ”‚   โ”œโ”€โ”€ lambo.png
โ”‚   โ”‚   โ”œโ”€โ”€ lambo2.png
โ”‚   โ”‚   โ”œโ”€โ”€ lancer.png
โ”‚   โ”‚   โ”œโ”€โ”€ lancer2.png
โ”‚   โ”‚   โ”œโ”€โ”€ landcruiser.png
โ”‚   โ”‚   โ”œโ”€โ”€ landcruiser2.png
โ”‚   โ”‚   โ”œโ”€โ”€ landcruiser3.png
โ”‚   โ”‚   โ”œโ”€โ”€ lexus.png
โ”‚   โ”‚   โ”œโ”€โ”€ lexus2.png
โ”‚   โ”‚   โ”œโ”€โ”€ lexus3.png
โ”‚   โ”‚   โ”œโ”€โ”€ mini.png
โ”‚   โ”‚   โ”œโ”€โ”€ mustang2.png
โ”‚   โ”‚   โ”œโ”€โ”€ mustang3.png
โ”‚   โ”‚   โ”œโ”€โ”€ patrol.png
โ”‚   โ”‚   โ”œโ”€โ”€ patrol2.png
โ”‚   โ”‚   โ”œโ”€โ”€ pickup.png
โ”‚   โ”‚   โ”œโ”€โ”€ pickup2.png
โ”‚   โ”‚   โ”œโ”€โ”€ pickup3.png
โ”‚   โ”‚   โ”œโ”€โ”€ porsche.png
โ”‚   โ”‚   โ”œโ”€โ”€ raptor.png
โ”‚   โ”‚   โ”œโ”€โ”€ raptor2.png
โ”‚   โ”‚   โ”œโ”€โ”€ sunny.png
โ”‚   โ”‚   โ”œโ”€โ”€ suv.png
โ”‚   โ”‚   โ”œโ”€โ”€ suv2.png
โ”‚   โ”‚   โ”œโ”€โ”€ taxi.png
โ”‚   โ”‚   โ”œโ”€โ”€ taxi2.png
โ”‚   โ”‚   โ”œโ”€โ”€ tida.png
โ”‚   โ”‚   โ”œโ”€โ”€ tida2.png
โ”‚   โ”‚   โ”œโ”€โ”€ tida3.png
โ”‚   โ”‚   โ”œโ”€โ”€ tow_truck.png
โ”‚   โ”‚   โ”œโ”€โ”€ tow_truck2.png
โ”‚   โ”‚   โ”œโ”€โ”€ tow_truck3.png
โ”‚   โ”‚   โ”œโ”€โ”€ truck2.png
โ”‚   โ”‚   โ”œโ”€โ”€ truck3.png
โ”‚   โ”‚   โ”œโ”€โ”€ van.png
โ”‚   โ”‚   โ”œโ”€โ”€ van2.png
โ”‚   โ”‚   โ”œโ”€โ”€ van3.png
โ”‚   โ”‚   โ”œโ”€โ”€ wrangler.png
โ”‚   โ”‚   โ”œโ”€โ”€ wrangler2.png
โ”‚   โ”‚   โ”œโ”€โ”€ wrangler3.png
โ”‚   โ”‚   โ””โ”€โ”€ wrangler4.png
โ”‚   โ”œโ”€โ”€ Icon/
โ”‚   โ”‚   โ””โ”€โ”€ icon.ico
โ”‚   โ”œโ”€โ”€ Road/
โ”‚   โ”‚   โ””โ”€โ”€ road1.png
โ””โ”€โ”€โ”€|

๐Ÿšฆ How to Run

  1. Install Python 3.14.3 and pygame-ce
  2. Clone this repository
  3. pip install -r requirements.txt
  4. Run Main.py:
python Main.py

๐Ÿ“ Design

The game is designed using object-oriented principles:

  • Game loop: Managed in Game.py, handles events, updates, and rendering.
  • Entities: Player and obstacle cars are separate classes in Entities/.
  • Settings: All constants and configuration in Settings.py.
  • Utils: High score management, randomization, and display helpers.
  • Assets: Images and sounds are loaded dynamically from the Assets/ folder.
  • Persistence: High scores are saved in a CSV file for replayability.

๐Ÿ“ฆ Requirements

  • Python 3.14.3
  • pygame-ce

Install dependencies:

Python 3.x (x>10)
pip install pygame-ce

๐Ÿ™ Credits

Developed by iammrranik for a Python midterm project.

About

๐ŸŽ๏ธ Python-based 2D car racing game featuring randomized obstacle spawning, real-time level scaling and persistent leaderboards. Optimized as a single-file portable executable.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages