Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Racing Car Game

A classic console-based racing game written in C++. Dodge incoming cars and aim for the highest score!

Features

  • 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.

Project Structure

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

Prerequisites

  • CMake (version 3.10 or higher)

  • 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 like conio.h and windows.h, so cross-platform support may require modifications).
  • Windows OS (Recommended due to console specific dependencies)

Quick Start

Build the Project

From the project root directory:

configuration\build.bat

This will:

  1. Create a build directory
  2. Configure the project with CMake
  3. Compile the source code
  4. Generate executable at build/Release/RacingCar.exe (or build/RacingCar.exe depending on generator)

Run the Application

configuration\run.bat

Or directly:

build\Release\RacingCar.exe

Clean Build Files

artifacts\clean.bat

Manual Build Commands

Using CMake

# 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

Using g++ Directly

# 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

How to Use

  1. Run the executable:

    build\Release\RacingCar.exe
  2. Menu Navigation:

    • 1: Start Game
    • 2: Instructions
    • 3: Quit
  3. Controls:

    • A or a: Move Left
    • D or d: Move Right
    • Esc: Pause/Exit to Menu
  4. Objective: Avoid the enemy cars moving down the screen. Each car dodged increases your score.

Build Configuration

The project uses CMake with the following settings:

  • C++ Standard: C++14
  • Project Name: RacingCar
  • Source Files: Located in src/ directory

Troubleshooting

"CMake not found"

"g++ not found"

  • Install MinGW-w64
  • Add MinGW bin folder to system PATH (e.g., C:\mingw64\bin)
  • Restart terminal/command prompt

Display Issues

  • Ensure you are running in a standard Windows Command Prompt (cmd.exe) or PowerShell. Check window size if graphics appear distorted.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages