A modern 2D game engine built with C/C++ and Lua scripting, featuring an Entity-Component System (ECS) architecture with cross-platform support for macOS and Linux.
- High Performance C/C++ Core: Fast, lightweight engine written in C with C++ extensions for graphics
- Entity-Component System: Flexible ECS architecture for modular game object design
- Lua Scripting (LuaJIT): Fast LuaJIT integration for game logic and rapid prototyping
- Cross-Platform: Native support for macOS (Metal) and Linux (OpenGL/GLFW)
- Sprite System: Animated sprites with frame-based animation support
- Shader Support: Custom GLSL pipeline (glslang/SPIR-V + SPIRV-Cross for Metal) for advanced effects
- Tilemap Rendering: Efficient tilemap system with support for multiple map types (grid, hexagonal, isometric)
- Camera System: 2D camera with viewport management
- Draw Lists: Optimized rendering with z-index depth sorting
- Collision Detection: Rectangle-based collision system with component integration
- GUI System: Style-driven GUI primitives and theming
- HTTP Client: Async HTTP requests exposed to Lua
- Job Queue: Asynchronous job queue for background work
- Audio: Platform audio playback (CoreAudio/AudioToolbox on macOS, OpenAL on Linux)
- Asset Management: Centralized asset loading for textures, sprites, maps, and scripts
- Input Handling: Cross-platform input state management
- Memory Management: Custom memory allocator with garbage collection for Lua
- macOS: Native Metal rendering with Cocoa window management
- Linux: OpenGL rendering with GLFW window management
- Asset Loading: Platform-agnostic filesystem abstraction
ESE uses a true ECS architecture where:
- Entities: Simple containers that hold components
- Components: Data structures that define entity properties and behaviors
- Systems: Process entities with specific component combinations
- SpriteComponent: Handles visual rendering and animation
- ColliderComponent: Manages collision detection and physics
- MapComponent: Renders tilemaps and world geometry
- TextComponent: Renders on-screen text
- ShapeComponent: Renders simple shapes; includes path variant
- LuaComponent: Links entities to Lua scripts for game logic
- RenderSystem: Processes all visual components
- CollisionSystem: Handles collision detection and response
- ScriptSystem: Executes Lua scripts for entity behavior
- AssetSystem: Manages loading and caching of game resources
- CMake 3.16 or higher
- C/C++ compiler with C99 and C++11 support
- LuaJIT (vendored; built automatically)
- Linux only: OpenGL, GLFW3, GLEW, OpenAL development packages
# Clone the repository
git clone https://github.com/zaun/entity-sprite-engine.git
cd entity-sprite-engine
# Create build directory
mkdir build && cd build
# Configure and build
cmake ..
make# Force macOS build (uses Metal rendering)
cmake -DFORCE_PLATFORM_MAC=ON ..
make# Force Linux build (uses OpenGL/GLFW)
cmake -DFORCE_PLATFORM_LINUX=ON ..
makeThe examples/simple directory contains a working demo that showcases:
- Entity creation and component management
- Sprite rendering and animation
- Collision detection
- Tilemap rendering
- Lua script integration
# From the build directory
# macOS (app bundle)
open examples/simple/simple_demo.app
# Linux (executable)
cd examples/simple
./simple_demo-- Create a new entity
local player = Entity.new()
-- Add a sprite component
local sprite_comp = EntityComponentSprite.new()
sprite_comp.sprite = "game:player_idle"
player.components.add(sprite_comp)
-- Add a collider component
local collider_comp = EntityComponentCollider.new()
collider_comp.rects.add(Rect.new(0, 0, 32, 32))
player.components.add(collider_comp)
-- Add Lua script for behavior
local script_comp = EntityComponentLua.new()
script_comp.script = "player.lua"
player.components.add(script_comp)-- Load sprite atlas
if asset_load_atlas("game", "player.json", true) then
print("Player sprites loaded successfully")
end
-- Load map data
if asset_load_map("game", "level.json") then
print("Level map loaded successfully")
end
-- Load and set shaders
if asset_load_shader("game", "shaders.glsl") then
set_pipeline("game:vertexShader", "game:fragmentShader")
endese/
โโโ src/
โ โโโ core/ # Engine core, asset management
โ โโโ entity/ # ECS implementation
โ โโโ graphics/ # Rendering and sprite systems
โ โโโ platform/ # Platform-specific code (macOS/Linux)
โ โโโ scripting/ # Lua engine integration
โ โโโ types/ # Core data structures
โ โโโ utility/ # Helper functions and data structures
โโโ examples/
โ โโโ simple/ # Working demo application
โโโ docs/ # API documentation
โโโ CMakeLists.txt # Build configuration
- Create component header and implementation files in
src/entity/components/ - Implement required component interface functions
- Add Lua bindings in the component's Lua integration file
- Register the component type in the Lua engine
The engine uses platform-specific implementations for:
- Window management
- Rendering (Metal on macOS, OpenGL on Linux)
- Filesystem operations
- Time and input handling
- C-style memory management for engine core
- Automatic garbage collection for Lua objects
- Custom memory allocator with safety checks
Detailed API documentation is available in the docs/ directory:
global.md- Global engine and Lua APIsentity.mdandentitycomponent.md- Entity and component systemdisplay.mdandgui.md- Rendering/display and GUImap.mdandmapcell.md- Map and map cell systemspoint.md,rect.md,vector.md,ray.md,tileset.md,uuid.md- Core types
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request