Skip to content

sefren/Blacksite

Repository files navigation

Blacksite Engine

Physics-Driven C++ Game Engine — Solo experimental project exploring what happens when physics isn't just a feature, it's the foundation.

Build Status Version C++17 Physics License

Blacksite is my personal C++ game engine experiment built around Jolt Physics with a physics-driven design philosophy. This is a learning project that explores modern engine architecture while keeping physics simulation at the core of everything.

New in v0.3.0-alpha: Complete architectural refactoring with event-driven systems, service locator pattern, and a fluent API that makes physics feel natural and immediate.


The Core Idea: Physics-Driven Everything

Traditional Approach: Physics as Add-on

// Physics is optional, easy to forget
auto object = engine.CreateObject();
object.AddComponent<MeshComponent>();
object.AddComponent<TransformComponent>();
// Oops! No physics - object just floats there

Blacksite Approach: Physics-Driven Design

// Physics is the foundation - everything else builds on it
auto cube = scene->SpawnEntity()
    .At({0, 5, 0})              // Physics position
    .Scale(2.0f)                // Physics scale
    .Color(1, 0, 0)             // Visual representation
    .Impulse({5, 0, 0});        // Physics interaction
    // Already falling, bouncing, colliding!

The difference? Physics drives the architecture, not the other way around. Every API call has immediate physical meaning.


Quick Start

Prerequisites

  • CMake 3.16+
  • C++17 compatible compiler (GCC 7+, Clang 10+)
  • OpenGL 3.3+ compatible graphics drivers
  • Linux/macOS (Windows support coming eventually)

1. Clone and Setup

git clone https://github.com/MintBlaster/BlacksiteEngine.git
cd BlacksiteEngine
./scripts/setup.sh  # One-time setup - installs dependencies

2. Launch the Physics Playground

./scripts/dev.sh editor     # Full physics testing suite

3. Your First Demo Scene

#include "blacksite/app/Application.h"
#include "blacksite/scene/SceneSystem.h"

class SimpleDemo : public Blacksite::Application {
public:
    SimpleDemo() : Application("Simple Demo", 1280, 720) {}

    void OnInitialize() override {
        // Create and switch to scene
        auto* sceneSystem = GetEngine().GetSystem<SceneSystem>();
        auto scene = sceneSystem->CreateScene<Scene>("DemoScene");
        sceneSystem->SwitchToScene("DemoScene");

        CreateSimpleWorld(scene.get());
    }

private:
    void CreateSimpleWorld(Scene* scene) {
        // Ground - explicitly make static
        auto ground = scene->SpawnEntity<CubeEntity>();
        ground.At({0, -1, 0})
              .Scale({20, 1, 20})
              .Color(0.3f, 0.6f, 0.3f)
              .MakeStatic();

        // Falling cube - physics by default
        auto cube = scene->SpawnEntity<CubeEntity>();
        cube.At({0, 5, 0})
            .Color(1, 0, 0);        // Falls immediately!

        // Camera setup
        scene->SetCameraPosition({8, 6, 8});
        scene->SetCameraTarget({0, 2, 0});
    }
};

int main() {
    SimpleDemo demo;
    if (!demo.Initialize()) return -1;
    return demo.Run();
}

Result: A red cube falls and bounces on green ground. Physics is immediate - no setup, no components to add.


Architecture: Clean but Simple

Event-Driven Systems

// Systems talk through events, not direct calls
EntitySystem publishes EntitySpawnedEvent
    ↓
PhysicsSystem subscribes and creates physics body
    ↓
RenderSystem subscribes and prepares rendering

Service Locator Pattern

// Clean dependency injection without constructor hell
auto* physics = ServiceLocator::GetServiceRaw<PhysicsSystem>();
auto* entities = ServiceLocator::GetServiceRaw<EntitySystem>();

// Your own system.
auto* yourSystem = ServiceLocator::GetServiceRaw<YourSystem>();

Fluent API

// Chain operations that feel natural
auto projectile = scene->SpawnEntity()
    .At({0, 2, 0})
    .Scale(0.5f)
    .Color(1, 0.5f, 0)
    .Impulse({10, 5, 0})        // Launch it!
    .SetRestitution(0.8f);      // Make it bouncy

What Actually Works (v0.3.0-alpha)

Solid Core Systems

  • Entity Management — Spawn, manipulate, and destroy with fluent API
  • Physics Integration — Jolt Physics with event-driven architecture
  • Scene Management — Multi-scene support with camera management
  • Basic Rendering — OpenGL with flat colors and basic lighting
  • Input System — Unified key/mouse API with 2D/3D axis mapping

Development Features

  • Build Automation — ./scripts/dev.sh for everything
  • Hot Reloading — Shader hot reloading (F5 in-game)
  • Debug Systems — Comprehensive logging and error handling

What's Missing (The Honest Truth)

  • Audio System — No sound at all
  • Advanced Rendering — Basic OpenGL only, no PBR/shadows
  • Asset Loading — Only primitive shapes (cubes, spheres, planes)
  • Networking — Single-player only
  • Scripting — C++ only, no Lua/Python
  • Advanced Physics — No constraints, joints, or complex shapes yet

Perfect For

  • Physics Experimentation — Immediate feedback, real-time manipulation
  • Rapid Prototyping — Quick physics-based game concepts
  • Education — Understanding how physics integrates with rendering

Not Ready For

  • Production Games — Missing too many core features
  • Complex Graphics — Basic rendering pipeline only
  • Large Projects — Solo hobby project scope

The API in Action

Immediate Physics Gratification

// Every line does something you can SEE
auto tower = scene->SpawnEntity()
    .At({0, 1, 0})
    .Color(0.8f, 0.2f, 0.2f);

auto wrecking_ball = scene->SpawnEntity()
    .At({-5, 3, 0})
    .Scale(2.0f)
    .Color(0.3f, 0.3f, 0.3f)
    .Impulse({15, 0, 0});       // SMASH!

Real-Time Physics Switching

// Switch physics states while simulation runs
auto box = scene->SpawnEntity().At({0, 5, 0});
box.MakeStatic();    // Freeze in mid-air
box.MakeDynamic();   // Resume falling
box.Push({5, 0, 0}); // Give it a shove

Interactive Physics Playground

// Built-in physics testing (./scripts/dev.sh editor)
// 1-5      = spawn different sizes (tiny to huge)
// Q-T      = spawn spheres only
// Z/X/C/V  = test patterns (pairs, scale test, tower, wall)
// SPACE    = random object
// N        = clear all
// G        = adjust gravity
// ESC      = exit

Development Workflow

Daily Development

# Most common commands
./scripts/dev.sh editor-fast    # Quick build and run editor
./scripts/dev.sh quick          # Quick engine test
./scripts/dev.sh clean          # Clean rebuild

# Code quality
./scripts/dev.sh format         # Format all code
./scripts/dev.sh info           # Project status

Advanced Building

# Full control
./scripts/build.sh --target editor --clean --run
./scripts/build.sh --release --jobs 8
./scripts/build.sh --help       # See all options

Project Structure

BlacksiteEngine/
├── blacksite/           # Engine core library
│   ├── include/blacksite/
│   └── src/
├── editor/              # Editor applicatoin
├── examples/            # Sample applications
├── scripts/             # Development workflow
└── docs/                # API documentation

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

High-Impact Areas:

  • Audio System — OpenAL integration with 3D spatial audio
  • Advanced Rendering — PBR materials, shadow mapping, deferred rendering
  • Asset Pipeline — Assimp integration, texture loading, model importing
  • Networking — Client-server architecture for multiplayer
  • Scripting — Lua/Python integration for gameplay programming

Learning Areas:

  • Documentation — API examples, tutorials, architecture guides
  • Testing — Unit tests, integration tests, performance benchmarks
  • Platform Support — Windows, macOS cross-platform development

License

This project is licensed under the MIT License — see the LICENSE file for details.


Acknowledgments

  • Jolt Physics — Professional-grade physics engine
  • Dear ImGui — Immediate mode GUI framework
  • GLFW — Cross-platform window and input
  • GLM — OpenGL Mathematics library
  • OpenGL — Cross-platform graphics API

Getting Started

Ready to explore modern engine architecture?

git clone https://github.com/MintBlaster/BlacksiteEngine.git
cd BlacksiteEngine
./scripts/setup.sh && ./scripts/dev.sh editor
# WASD+E/Q to move camera, Left Click to spawn cubes!

Perfect for: Learning engine architecture • Physics experimentation • Rapid prototyping • Educational projects

Remember: This is a learning project focused on physics-first design—excellent for understanding concepts and trying ideas!

About

Physics-driven C++ game engine where physics simulation is the foundation, not an add-on.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages