Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

154 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A 2D real-time grand-strategy game engine and a game prototype built on it. Written in C++ on SDL2.

screenshot

The repo has two targets:

  • libcapri - the engine. Renders a tile map with smoothed tile borders and objects on the tiles, and provides a small UI framework. Designed to handle large maps — on the order of a million tiles with tens of thousands of objects, in real time.
  • Regnum - an early game prototype built on top of libcapri.

Building

Built with CMake. Requires the SDL2 and SDL2_ttf libraries.

mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make regnum

This will create exec file in build directory; on Linux, run it with

./regnum

How it works (engine)

  • Pathfinding - hierarchical, Dijkstra-based. Movement isn't limited to the 8 grid directions - a tile connects to more than 8 neighbours in the path graph. Paths are searched over a two-level graph: a coarse graph between hubs (villages/towns) and a fine per-tile graph. Objects also have a movement-range limit unless they pass through a hub - mirroring real-army supply constraints.
  • Map rendering - viewport culling. Only visible tiles are drawn; scrolling redraws just the newly exposed edge, not the whole view. (No zoom yet; planned two zoom levels plus a cached minimap.)
  • Smoothed borders — per-edge autotiling. Each tile border is drawn as 4 edges; each edge is rendered as one of 9 variants selected from the neighbouring edges.
  • Objects - spatial index + culling. A simple spatial index (per-tile buckets keyed by (x, y)), culled to the viewport, drawn in two layers.
  • UI framework. Hierarchical widgets, row/column layout, mostly immediate-mode, bubbling events.

Status

An older project from my university years and shortly after; not actively maintained.

About

2d grand strategy game engine in SDL2 and a draft game on top of that.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages