A classic console-based racing game written in C++. Dodge incoming cars and aim for the highest score!
- Interactive Menu: Simple navigation for starting games, viewing instructions, and exiting.
- Smooth Controls: Responsive keyboard input for car movement.
- Score System: Tracks your progress as you successfully dodge enemies.
- Console Graphics: Uses standard console output for rendering the game state.
Racing-Car/
├── CMakeLists.txt # CMake build configuration
├── configuration/
│ ├── build.bat # Build script
│ └── run.bat # Run script
├── artifacts/
│ └── clean.bat # Clean build files (if applicable)
└── src/
├── main.cpp # Main program entry point
├── Game.cpp # Core game logic and loop
├── Game.h
├── Car.cpp # Player car implementation
├── Car.h
├── Enemy.cpp # Enemy car implementation
├── Enemy.h
├── ConsoleUtils.cpp # Console manipulation utilities
└── ConsoleUtils.h
-
CMake (version 3.10 or higher)
- Download: https://cmake.org/download/
- Add to system PATH during installation
-
C++ Compiler supporting C++14 or later
- MinGW-w64 (for Windows): https://sourceforge.net/projects/mingw-w64/
- GCC (for Linux):
sudo apt install build-essential cmake(Note: This project uses Windows-specific headers likeconio.handwindows.h, so cross-platform support may require modifications).
-
Windows OS (Recommended due to console specific dependencies)
From the project root directory:
configuration\build.batThis will:
- Create a
builddirectory - Configure the project with CMake
- Compile the source code
- Generate executable at
build/Release/RacingCar.exe(orbuild/RacingCar.exedepending on generator)
configuration\run.batOr directly:
build\Release\RacingCar.exeartifacts\clean.bat# Create and enter build directory
mkdir build
cd build
# Configure project
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
# Build
cmake --build . --config Release
# Return to root
cd ..
# Run
build\Release\RacingCar.exe# Create build directory
mkdir build
# Compile
g++ -std=c++17 -O2 -Wall -Wextra -I./src ^
src/Car.cpp ^
src/ConsoleUtils.cpp ^
src/Enemy.cpp ^
src/Game.cpp ^
src/main.cpp ^
-o build/Release/RacingCar.exe
# Run
build\Release\RacingCar.exe-
Run the executable:
build\Release\RacingCar.exe
-
Menu Navigation:
1: Start Game2: Instructions3: Quit
-
Controls:
Aora: Move LeftDord: Move RightEsc: Pause/Exit to Menu
-
Objective: Avoid the enemy cars moving down the screen. Each car dodged increases your score.
The project uses CMake with the following settings:
- C++ Standard: C++14
- Project Name: RacingCar
- Source Files: Located in
src/directory
- Install CMake from https://cmake.org/download/
- Add CMake to system PATH
- Restart terminal/command prompt
- Install MinGW-w64
- Add MinGW
binfolder to system PATH (e.g.,C:\mingw64\bin) - Restart terminal/command prompt
- Ensure you are running in a standard Windows Command Prompt (cmd.exe) or PowerShell. Check window size if graphics appear distorted.