Skip to content

Repository files navigation

Moonaut Engine

A lightweight game engine written in C with Lua scripting support. Designed for simplicity, featuring a tag-based asset system, real-time physics, and multiple software-rendering shading modes with ~20 effects.

Image

Image

Features

  • Tag-Based Asset System: Reflective data structures for materials, models, entities, and scenarios
  • Physics Simulation: Built-in rigid body dynamics with collision detection
  • Rendering Pipeline: Multiple shading modes (Wireframe, Flat, Gouraud, Phong) with about ~20 effects that can be combined and individually tweaked.
  • Lua Scripting: Full Lua integration for gameplay logic and entity manipulation
  • Hot Reloading: Live script updates during development

How It Works

Moonaut Engine operates on a tag-based architecture where all game assets—materials, models, entities, and scenarios—are defined as structured data with reflection capabilities. This allows for efficient serialization and runtime manipulation of game objects. The engine uses a scenario system to organize entities in a world, each with optional physics bodies and visual representations.

At its core, the engine runs a fixed-timestep physics simulation integrated with a software rasterization renderer. Entities can have rigid bodies for collision and dynamics, rendered using various shading techniques from simple wireframes to advanced Phong lighting. Lua scripting provides the glue, allowing developers to create entities, apply forces, control cameras, and manipulate the scene in real-time through a comprehensive API that exposes both low-level physics and high-level tag operations.

Building

CMake, Ninja, & Clang

The Clang Cmake presets are what I've been using for development. I've included some placeholder CMake presets for GCC, VisualStudio, and XCode, but they are largely untested.

All testing/development has been done under Linux & Windows. MacOS has never been tested.

Make sure to install CMake & Ninja. LLVM/Clang is recommended as that's the main compiler used for development on both Linux & Windows. But you can use MSVC or GCC instead.

If opting for Clang with VS Code, there's a clangd extension that will give nice IDE/LSP support.

On Windows: If using the Clang preset make sure the clang compiler is properly set up in your System Path.

List the presets:

If you opted NOT to use LLVM/Clang, you can list other CMake presets and pick what matches the toolchain you chose (or add your own if its not covered).

cmake --list-presets

Select a preset for your system, here we will use the clang-release preset:

cmake --preset clang-release

Build the preset:

cmake --build --preset clang-release

And then to run the executable on Linux:

./build/clang-release/Moonaut

or on Windows:

./build/clang-release/Moonaut.exe

About

ANSI C89 game engine utilizing software-rendering with minimal library usage. Lua scripting for gameplay logic.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages