Skip to content

3mr-mahmoud/turbo-rush-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Turbo Rush - 3D Racing Game

A high-performance 3D racing game built with OpenGL and modern C++17, featuring advanced graphics rendering techniques and an Entity-Component-System (ECS) architecture.

🏁 Game Overview

Turbo Rush is an exciting 3D racing game where players control a car through a dynamic track while avoiding obstacles. The game features:

  • Real-time 3D racing with smooth controls
  • Dynamic obstacle avoidance with collision detection
  • Timer-based gameplay with survival mechanics
  • Advanced graphics rendering with lighting, post-processing effects, and sky rendering
  • Multiple game states including menu, play, win, and lose states

🎮 Gameplay

  • Objective: Survive as long as possible while avoiding roadblocks
  • Controls:
    • WASD/Arrow Keys: Control car movement
    • Space: Start game from menu
    • Escape: Return to menu or exit game
  • Game Mechanics:
    • Timer counts down from 120 seconds
    • Player has limited hits (20 by default)
    • Collision with roadblocks reduces hit count
    • Surviving the timer leads to victory
    • Running out of hits leads to defeat

🏗️ Architecture

Core Systems

The game is built using a robust Entity-Component-System (ECS) architecture:

  • Entities: Game objects (car, camera, roadblocks, etc.)
  • Components: Data containers (Transform, MeshRenderer, Camera, etc.)
  • Systems: Logic processors (ForwardRenderer, CollisionSystem, etc.)

Key Components

  • Transform: Position, rotation, and scale management
  • MeshRenderer: 3D model rendering with materials
  • Camera: View and projection management
  • FreePlayerController: Player input handling
  • Collider: Collision detection and response
  • Light: Dynamic lighting system

Rendering Pipeline

The game features a sophisticated forward rendering pipeline with:

  • Shader-based rendering with vertex and fragment shaders
  • Material system supporting textured and lit materials
  • Pipeline state management for depth testing, blending, and culling
  • Post-processing effects including vignette and chromatic aberration
  • Sky sphere rendering for immersive environments
  • Multiple light support with different light types

🛠️ Technical Features

Graphics Engine

  • OpenGL 4.0+ with modern rendering techniques
  • GLFW for window management and input handling
  • GLM for mathematics and transformations
  • Dear ImGui for user interface elements
  • STB Image for texture loading

Advanced Rendering

  • PBR (Physically Based Rendering) materials
  • Multiple texture maps: Albedo, Specular, Roughness, Ambient Occlusion, Emission
  • Dynamic lighting with point, directional, and spot lights
  • Post-processing pipeline with framebuffer rendering
  • Transparency handling with proper depth sorting

Asset Management

  • 3D Models: OBJ format support (car, road, obstacles)
  • Textures: Multiple formats with sampler configuration
  • Shaders: GLSL vertex and fragment shaders
  • Scene Deserialization: JSON-based scene configuration

📁 Project Structure

turbo-rush-game/
├── assets/                 # Game assets
│   ├── models/            # 3D models (.obj)
│   ├── shaders/           # GLSL shaders
│   ├── textures/          # Image textures
│   └── postprocess/       # Post-processing shaders
├── config/                # Configuration files
│   ├── app.jsonc         # Main application config
│   └── [test-configs]/   # Testing configurations
├── source/                # Source code
│   ├── common/           # Core engine components
│   │   ├── components/   # ECS components
│   │   ├── systems/      # ECS systems
│   │   ├── ecs/          # Entity-Component-System
│   │   ├── material/     # Material system
│   │   ├── mesh/         # Mesh handling
│   │   ├── shader/       # Shader management
│   │   └── texture/      # Texture system
│   ├── states/           # Game states
│   └── main.cpp          # Application entry point
├── scripts/              # Build and testing scripts
├── expected/             # Expected test outputs
└── vendor/               # Third-party libraries

🚀 Building and Running

Prerequisites

  • C++17 compatible compiler (Visual Studio 2017+, GCC 9+, or Clang 5+)
  • CMake 3.17 or higher
  • OpenGL 4.0+ compatible graphics card

Build Instructions

  1. Clone the repository:

    git clone <repository-url>
    cd turbo-rush-game
  2. Generate build files:

    mkdir build
    cd build
    cmake ..
  3. Build the project:

    cmake --build .
  4. Run the game:

    # From project root
    ./bin/GAME_APPLICATION.exe

Configuration Options

The game can be configured using JSON files:

# Run with custom configuration
./bin/GAME_APPLICATION.exe -c='config/app.jsonc'

# Run for specific number of frames (useful for testing)
./bin/GAME_APPLICATION.exe -c='config/app.jsonc' -f=10

Testing

The project includes comprehensive testing infrastructure:

# Run all tests (PowerShell)
./scripts/run-all.ps1

# Run specific test group
./scripts/run-all.ps1 -tests sampler-test

# Compare results with expected outputs
./scripts/compare-all.ps1

🎯 Learning Objectives

This project demonstrates advanced computer graphics concepts:

  1. Shader Programming: Vertex and fragment shader implementation
  2. GPU Rendering: Buffer management and vertex array objects
  3. 3D Transformations: Matrix-based object positioning and orientation
  4. Rendering Techniques: Depth testing, face culling, blending
  5. Texture Mapping: Image sampling and filtering
  6. Material System: Shader-pipeline-material integration
  7. ECS Framework: Entity-Component-System architecture
  8. Forward Rendering: Multi-pass rendering with transparency
  9. Sky Rendering: Background environment rendering
  10. Post-Processing: Framebuffer-based image effects
  11. Lighting Models: Multiple light types and PBR materials
  12. Game Development: Complete game implementation

🔧 Development Features

Phase 1 Requirements ✅

  • Shader Program implementation
  • Mesh rendering with vertex buffers
  • Transform system with matrices
  • Pipeline state management
  • Texture loading and sampling
  • Sampler configuration
  • Material system with inheritance
  • Entity-Component-System framework
  • Forward renderer with transparency
  • Sky sphere rendering
  • Post-processing effects

Phase 2 Requirements ✅

  • Advanced lighting system
  • Complete game implementation
  • 3D model usage
  • Multiple light support
  • PBR texture mapping
  • Sky rendering
  • Custom post-processing effects
  • 3D motion and physics
  • Collision detection
  • Game logic and objectives
  • Scene deserialization
  • Multiple game states

🎨 Graphics Features

Rendering Pipeline

  • Forward Rendering with multiple passes
  • Depth-sorted transparency rendering
  • Framebuffer-based post-processing
  • Sky sphere background rendering

Materials and Shaders

  • PBR Materials with multiple texture maps
  • Custom shaders for different material types
  • Lighting shaders with multiple light support
  • Post-processing shaders for visual effects

Lighting System

  • Point lights for local illumination
  • Directional lights for global lighting
  • Spot lights for focused illumination
  • Attenuation and cone angles support

🐛 Troubleshooting

Common Issues

  1. OpenGL Version: Ensure your graphics card supports OpenGL 4.0+
  2. CMake Version: Use CMake 3.17 or higher
  3. Compiler Support: Ensure C++17 compatibility
  4. Asset Loading: Verify all asset files are present in the assets directory

Performance Optimization

  • The game uses efficient rendering techniques for smooth performance
  • Post-processing effects are optimized for real-time rendering
  • Collision detection uses simplified bounding box calculations
  • Texture streaming and LOD systems are implemented

📚 Resources

Documentation

Learning Resources

👥 Team

This project was developed as a collaborative effort demonstrating advanced computer graphics concepts and game development techniques.


Turbo Rush - Experience the thrill of high-speed racing with cutting-edge graphics technology! 🏎️💨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors