Skip to content

lextpf/rift

Repository files navigation

rift

A modern 2.5D game engine built with C++23.

🏠 Mainpage | 🧱 Building | 🏛️ Architecture | 🤝 Contributing

Engine Genre Windows CMake OpenGL Vulkan License
Quality Gate Status Maintainability Rating Reliability Rating
build tests
Sponsor

A modern 2.5D game engine built with C++23, featuring dual OpenGL 4.6 and Vulkan 1.4 rendering backends that can be switched at runtime. It includes dynamic world simulation with a full day/night cycle, weather effects, and NPC interactions, alongside a built-in level editor for rapid content creation. Designed for tile-based RPGs with a focus on performance, flexibility, and visual polish.


Game

Important

Assets Not Included

This engine ships without game assets (sprites, tilesets, fonts, maps). To run the engine, you will need to provide your own:

  • Source free/open-licensed sprites and tilesets (e.g., from OpenGameArt, itch.io)
  • Place them in the assets/ directory following the structure in Project Structure
  • Wire them into the engine by adjusting the loading paths (e.g., Game.cpp L233, L273)

The engine will not run without valid assets in place.

/* ============================================================================================== *
 *                                                                                                
 *                                                            ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠳⣶⡤
 *                                                            ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠠⣾⣦⡀
 *                                                            ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣈⣻⡧⢀
 *           :::::::::  ::::::::::: :::::::::: :::::::::::    ⢷⣦⣤⡀⠀⢀⣠⣤⡆⢰⣶⣶⣾⣿⣿⣷⣕⣡⡀
 *           :+:    :+:     :+:     :+:            :+:        ⠘⣿⣿⠇⠀⣦⡀⠉⠉⠈⠉⠁⢸⣿⣿⣿⣿⡿⠃
 *           +:+    +:+     +:+     +:+            +:+        ⠀⠀⠀⣀⣴⣿⣿⣄⣀⣀⣀⢀⣼⣿⣿⣿⠁
 *           +#++:++#:      +#+     :#::+::#       +#+        ⠀⠀⠀⠀⠉⢩⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀
 *           +#+    +#+     +#+     +#+            +#+        ⠀⠀⠀⠀⠀⣸⣿⣿⡿⢻⣿⣿⣿⣿⡿⢿⠇
 *           #+#    #+#     #+#     #+#            #+#        ⠀⠀⠀⠀⢰⣿⣿⣿⠰⠙⠁⠈⣿⣿⠱⠘
 *           ###    ### ########### ###            ###        ⠀⠀⠀⠀⢸⡏⣾⡿⠁⠀⠀⠀⢿⣼⣷⠁
 *                                                            ⠀⠀⠀⠀⠘⠷⢿⣧⡀⠀⠀⠀⠈⠛⢿⣆
 *                                                            ⠀⠀⠀⠀⠀⠀⠀⠉⠉⠀⠀⠀⠀⠀⠀⠈
 *                                  << G A M E   E N G I N E >>                        
 *                                                                                                  
 * ============================================================================================== */

Features

Dual Rendering Backend

Switch between OpenGL 4.6 and Vulkan 1.4 at runtime with a single keypress (F1).

Warning

Vulkan is work-in-progress. Runtime switching can cause missing textures or visual glitches. OpenGL is recommended for now.

Dynamic Day/Night Cycle

A complete time-of-day system drives ambient lighting, sky colors, celestial bodies, and atmospheric effects:

---
config:
  look: handDrawn
  theme: mc
  themeVariables:
    fontSize: 18px
  layout: elk
---
graph LR
    classDef night fill:#1a1a2e,stroke:#9aa4c0,stroke-width:2.5px,color:#ffffff,font-weight:800
    classDef dawn  fill:#614385,stroke:#d7a3ff,stroke-width:2.5px,color:#ffffff,font-weight:800
    classDef day   fill:#f39c12,stroke:#7a3e00,stroke-width:2.5px,color:#ffffff,font-weight:900
    classDef dusk  fill:#c0392b,stroke:#ff9a9a,stroke-width:2.5px,color:#ffffff,font-weight:800

    N["Night 🌙✨"]:::night --> D["Dawn 🌅🕊️"]:::dawn --> M["Morning ☀️🌿"]:::day --> A["Afternoon 🌞🕶️"]:::day --> DU["Dusk 🌇🔥"]:::dusk --> E["Evening 🌃🌟"]:::night --> N
Loading
  • Sun and moon god rays with arc-based positioning
  • Star field with shooting stars and atmospheric glow
  • Smooth color transitions between time periods

Multi-Layer Tilemap System

Efficient tile-based world rendering with 8 configurable layers:

---
config:
  look: handDrawn
  theme: mc
  themeVariables:
    fontSize: 18px
  layout: elk
---
flowchart LR
  classDef ov fill:#2e1f5e,stroke:#8b5cf6,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef fg fill:#134e3a,stroke:#10b981,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef ob fill:#4a3520,stroke:#f59e0b,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef gr fill:#1e3a5f,stroke:#3b82f6,stroke-width:2.5px,color:#e2e8f0,font-weight:800

  O["7–6 Overlay 🌦️✨<br/>UI - Weather 🧭"]:::ov
  F["5–4 Foreground 🧍‍♂️⚔️<br/>Front of Entities 👑"]:::fg
  B["3–2 Objects 🏠🪨🌲<br/>Buildings - Rocks - Trees 🧱"]:::ob
  G["1 Detail 🍃🛤️🪴<br/>Grass - Paths - Deco 🎨"]:::gr
  T["0 Ground 🗺️🟫<br/>Base Terrain 🌍"]:::gr

  O --> F --> B --> G --> T

Loading

Advanced Rendering Features

---
config:
  look: handDrawn
  theme: mc
  themeVariables:
    fontSize: 18px
  layout: elk
---
flowchart LR
  classDef batch fill:#1e3a5f,stroke:#3b82f6,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef sort fill:#134e3a,stroke:#10b981,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef proj fill:#4a3520,stroke:#f59e0b,stroke-width:2.5px,color:#e2e8f0,font-weight:800
  classDef fx fill:#2e1f5e,stroke:#8b5cf6,stroke-width:2.5px,color:#e2e8f0,font-weight:800

  subgraph Pipeline["Rendering Pipeline 🎨"]
    B["Sprite Batching 📦<br/>Draw Call Optimization 🚀"]:::batch
    Y["Y-Sorting 🧭<br/>Depth Ordering 🪜"]:::sort
    P["Perspective 👁️‍🗨️<br/>World Curvature 🌍"]:::proj
    N["No-Projection 🏗️<br/>Upright Structures 🧱"]:::proj
    FX["Particles ✨<br/>Zone Spawning 🌪️"]:::fx
  end

  B --> Y
  Y --> P
  Y --> N
  P --> FX
  N --> FX
Loading
  • Sprite batching groups draw calls for optimal GPU efficiency
  • Y-sorting ensures correct depth ordering of entities and tiles
  • Perspective projection adds world curvature and vanishing point effects
  • No-projection tiles keep buildings and signs upright
  • Particle systems spawn effects within defined zones

In-Game Level Editor

Press E to toggle a full-featured editor:

  • Tile placement with multi-tile selection and rotation
  • Collision and navigation map painting
  • Tile elevation for height variation
  • NPC placement and patrol route configuration
  • Animation definition tools

Entity System

  • Player character with 8-directional movement and animation
  • NPCs with autonomous patrol behavior and pathfinding
  • Dialogue system supporting branching conversations with quests

Architecture

---
config:
  look: handDrawn
  theme: mc
  themeVariables:
    fontSize: 18px
  layout: elk
---
graph LR
    classDef core fill:#1e3a5f,stroke:#3b82f6,color:#e2e8f0
    classDef render fill:#2e1f5e,stroke:#8b5cf6,color:#e2e8f0
    classDef world fill:#134e3a,stroke:#10b981,color:#e2e8f0
    classDef entity fill:#4a3520,stroke:#f59e0b,color:#e2e8f0

    Game((Game)):::core

    subgraph Rendering["Rendering"]
        IRenderer[IRenderer]:::render
        OpenGL[OpenGLRenderer]:::render
        Vulkan[VulkanRenderer]:::render
    end

    subgraph World["World"]
        Tilemap[Tilemap]:::world
        Collision[CollisionMap]:::world
        Navigation[NavigationMap]:::world
    end

    subgraph Entities["Entities"]
        Player[PlayerCharacter]:::entity
        NPC[NonPlayerCharacter]:::entity
    end

    Game --> Rendering
    Game --> World
    Game --> Entities
Loading

Technology Stack

Component Technology
Language C++23
Graphics OpenGL 4.6 / Vulkan 1.4
Windowing GLFW 3.3+
Math GLM
Image Loading stb_image
Font Rendering FreeType 2
Build System CMake 3.10+

Quick Start

Prerequisites

  • CMake 3.10+
  • C++23 compatible compiler (MSVC 2022+)
  • OpenGL 4.6 compatible GPU (or Vulkan 1.4 capable)

Windows

# 1. Clone the repository
git clone https://github.com/lextpf/rift.git
cd rift

# 2. Run setup script to download dependencies
.\setup.ps1

# 3. Build the project
.\build.bat

# 4. Run the game
.\build\Release\rift.exe

Controls

General Keybinds

Gameplay

Key Action
W/A/S/D Move player (8-directional)
Shift Run (1.5x speed)
B Toggle bicycle mode (2.0x speed)
F Talk to NPC when facing
X Copy/restore NPC appearance
C Cycle characters
Ctrl+Scroll Zoom camera
Arrow Keys Pan camera
Z Reset zoom to 1.0x
Space Free camera mode

Dialogue

Key Action
W/S or Up/Down Navigate dialogue options
Enter/Space Confirm selection / advance
Escape End dialogue

Movement Modes

Mode Speed Collision
Walking 100 px/s Strict (full hitbox)
Running 150 px/s Relaxed (center point)
Bicycle 200 px/s Relaxed (center point)

Editor

Key Action
E Toggle editor mode
1-8 Select tilemap layer
T Toggle tile picker
R Rotate selection 90 deg
Delete Remove tile at cursor
S Save map to JSON
L Load map from JSON
M Toggle navigation editing
N Toggle NPC placement
H Toggle elevation editing
B Toggle billboard projection
Y Toggle Y-sort editing
J Toggle particle zone editing
K Toggle animated tile editing
X Toggle corner cut blocking on tile
, / . Cycle types (NPC/particle/anim)
Left Click Place tile/NPC/zone
Right Click Toggle collision/navigation
Arrows Pan tile picker
Shift+Arrows Pan tile picker (fast)
Scroll Pan tile picker
Ctrl+Scroll Zoom

Debug and Visual

Key Action
F1 Switch renderer (OpenGL/Vulkan)
F2 Toggle debug overlays (collision, navigation, anchors)
F3 Toggle FPS/position display
F4 Toggle 3D globe effect
F5 Cycle time of day (day/evening/night/morning)
Up/Down Adjust 3D globe intensity

For detailed editor controls, see the Editor Guide.

Documentation

---
config:
  look: handDrawn
  theme: mc
  themeVariables:
    fontSize: 18px
  layout: elk
---
graph LR
    classDef guide fill:#1e3a5f,stroke:#3b82f6,color:#e2e8f0
    classDef tech fill:#134e3a,stroke:#10b981,color:#e2e8f0

    subgraph Guides
        Setup[Setup]:::guide
        Building[Building]:::guide
        Editor[Editor]:::guide
    end

    subgraph Technical
        Arch[Architecture]:::tech
        Render[Rendering]:::tech
        Time[Time System]:::tech
        Collision[Collision]:::tech
    end

    Setup --> Building --> Editor
    Arch --> Render
    Arch --> Time
    Arch --> Collision
Loading
Document Description
Setup Guide Install dependencies and configure your environment
Building Guide Compile on Windows
Architecture Engine design, game loop, system relationships
Rendering Pipeline Coordinate systems, transformations, batching
Time System Day/night cycle, celestial mechanics, lighting
Collision & Pathfinding AABB collision, navigation, NPC AI
Editor Guide Level editor usage and tools

Generating API Docs

# Install Doxygen
# Windows: choco install doxygen

# Generate documentation
doxygen Doxyfile

# Open docs/html/index.html in your browser

File Formats

  • .json - Map data (layers, tiles, NPCs)
  • .png - Sprites (32-bit RGBA)
  • .ttf - Fonts (TrueType)
  • .vert/.frag - Shaders (GLSL 450)

Project Structure

rift/
|-- src/                      # Source code
|   |-- main.cpp              # Entry point
|   |-- Game.cpp/h            # Core game loop and systems
|   |-- IRenderer.h           # Renderer interface
|   |-- OpenGLRenderer.*      # OpenGL backend
|   |-- VulkanRenderer.*      # Vulkan backend
|   |-- Tilemap.*             # World and tile management
|   |-- TimeManager.*         # Day/night cycle
|   |-- SkyRenderer.*         # Celestial rendering
|   |-- PlayerCharacter.*     # Player entity
|   |-- NonPlayerCharacter.*  # NPC entities
|   +-- ...
|-- assets/                   # Game assets
|   |-- fonts/                # Font files (TTF) for UI and text rendering
|   |-- non-player/           # NPC and enemy sprite images
|   |-- overworld/            # World environment, tilesets, and map images
|   |-- player/               # Player character sprite sheets and animations
|   +-- particles/            # Small particle effect images (sparks, dust, etc.)
|-- shaders/                  # GLSL shaders
|   +-- sprite.vert/frag      # Sprite rendering
|-- docs/                     # Documentation
+-- external/                 # Third-party dependencies

Contributing

Contributions are welcome! Please read the Contributing Guidelines before submitting pull requests.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Run tests and ensure the build passes
  5. Commit with descriptive messages
  6. Push to your fork and open a Pull Request

License

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

Acknowledgments

  • GLFW - Window and input handling
  • GLM - Mathematics library
  • stb_image - Image loading
  • FreeType - Font rendering
  • Vulkan SDK - Vulkan development tools
  • Claude - AI coding assistant by Anthropic
  • Codex - AI coding assistant by OpenAI
  • DeviantArt - Pixel art for characters and tilesets
  • Sora - Particle effect generation

About

A C++23 2.5D RPG engine with runtime-switchable OpenGL 4.6/Vulkan 1.4, tilemap for dynamic world simulation, NPCs, and a built-in level editor.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages