A professional 2D game engine built with C++17 and Lua scripting.
FR-Ocean Engine is a professional-grade 2D game engine designed for rapid game development. With a component-based architecture, Lua scripting, and Box2D physics, it provides everything you need to create sophisticated 2D games.
Built with modern C++17 and industry-standard libraries, FR-Ocean Engine combines performance with ease of use, making it ideal for both indie developers and students learning game development.
- Component-Based: Flexible actor-component architecture inspired by Unity
- Lua Scripting: Write game logic in Lua for rapid iteration
- Full Physics: Box2D integration with collision detection and raycasting
- Deferred Rendering: Optimized sprite rendering with z-order sorting
- Cross-Platform: Write once, build for Windows, macOS, and Linux
- Well-Documented: Comprehensive API documentation and examples
- MIT Licensed: Free for commercial and personal projects
- Component-based architecture with reusable, composable components
- JSON-based scene definitions with hot-swapping support
- Dynamic game objects with runtime component addition/removal
- Modern C++17 with unified codebase for all platforms
- Hardware-accelerated 2D sprite rendering via SDL2
- Deferred rendering pipeline with batched, sorted draw calls
- Camera system with position and zoom control
- Z-order sorting for sprite layering
- Transform support (position, rotation, scale, pivot)
- RGBA color modulation and alpha blending
- TrueType font rendering with SDL2_ttf
- Screen-space UI rendering
- Box2D integration for industry-standard 2D physics
- Dynamic, kinematic, and static body types
- Box and circle collision shapes
- Trigger volumes for sensor-based overlap detection
- Collision callbacks (OnCollisionEnter/Stay/Exit)
- Single and multi-hit raycasting
- Multi-channel mixing with 16 simultaneous channels via SDL2_mixer
- WAV, OGG, and MP3 format support
- Seamless audio looping for music
- Per-channel volume control
- Lua 5.4 with LuaBridge C++ integration
- Component lifecycle callbacks (OnStart, OnUpdate, OnLateUpdate, OnDestroy)
- Full API access to engine systems from Lua
- Component inheritance via Lua metatables
- Data-driven design with JSON configuration
- Modern CMake build system
- Vendored dependencies (no external package managers required)
- Built-in logging system with multiple severity levels
- Debug pixel and rectangle drawing for visualization
- Runtime resources path override via command-line
- Visual Studio 2019 or newer
- CMake 3.16+
- Xcode 12+ or Command Line Tools
- CMake 3.16+
- GCC 9+ or Clang 9+
- CMake 3.16+
- SDL2, SDL2_image, SDL2_mixer, SDL2_ttf development packages
Windows:
git clone https://github.com/jackgaff/fr-ocean-engine.git
cd fr-ocean-engine
mkdir build && cd build
cmake -G "Visual Studio 17 2022" ..
cmake --build . --config ReleasemacOS:
git clone https://github.com/jackgaff/fr-ocean-engine.git
cd fr-ocean-engine
mkdir build && cd build
cmake ..
cmake --build . --config ReleaseFor Xcode project generation:
cmake -G Xcode ..Linux:
git clone https://github.com/jackgaff/fr-ocean-engine.git
cd fr-ocean-engine
mkdir build && cd build
cmake ..
makeThe executable outputs to build/bin/game_engine with resources copied to build/bin/resources/.
./game_engine [options]
Options:
--resources <path> Override resources directory (default: resources/)
--debug Enable debug logging
--version Print version and exit
--help Print help message
-- ConstantMovement.lua
ConstantMovement = {
x_vel = 0,
y_vel = 0,
}
function ConstantMovement:OnStart()
self.rigidbody = self.actor:GetComponent("Rigidbody")
end
function ConstantMovement:OnUpdate()
local pos = self.rigidbody:GetPosition()
pos.x = pos.x + self.x_vel
pos.y = pos.y + self.y_vel
self.rigidbody:SetPosition(pos)
endfr-ocean-engine/
├── build/ # Build directory (generated)
├── game_engine/ # Engine source code
│ ├── Actor.cpp/hpp # Actor system
│ ├── Engine.cpp/hpp # Main game loop
│ ├── ComponentDB.cpp/hpp # Lua component system
│ └── ... # Other engine sources
├── resources/ # Game resources
│ ├── game.config # Game configuration
│ ├── rendering.config # Rendering settings
│ ├── scenes/ # Scene definition files
│ ├── actor_templates/ # Actor templates
│ ├── component_types/ # Lua component scripts
│ ├── images/ # Image files
│ ├── fonts/ # Font files
│ └── audio/ # Audio files
├── resources.example/ # Example Space Shooter game
├── vendor/ # Third-party libraries
└── CMakeLists.txt # CMake build configuration
- API Reference: Complete Lua API documentation with examples
- Architecture: Engine design, subsystems, and data flow
- Code Standards: Coding conventions and best practices
- Contributing Guide: How to contribute to the project
- Changelog: Version history and release notes
The engine includes three example games to demonstrate different capabilities:
- Player movement and shooting
- Enemy spawning and AI
- Collision detection with triggers
- Score tracking and game over state
- Physics-based player movement with jumping
- Ground detection via raycasting
- Collectible coins with trigger volumes
- Smooth camera following
- Multi-platform level design
./build/bin/game_engine --resources resources.platformer/- Match-3 puzzle gameplay
- Grid-based piece matching
- Score tracking with progress bar
- Move counter and win/lose conditions
- Mouse-based selection and swapping
./build/bin/game_engine --resources resources.puzzle/Ensure you have a resources/ directory containing game.config and rendering.config.
Font files must be placed in resources/fonts/ with .ttf extension.
- Windows: Ensure SDL2.dll is in the same directory as the executable
- macOS: SDL2 frameworks should be in
build/bin/Frameworks/ - Linux: Install SDL2 development packages:
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
- Check the component file exists in
resources/component_types/ - Verify the filename matches the type name (case-sensitive)
- Check for Lua syntax errors in console output
Typical performance on modern hardware (Release build, 1080p):
- 1000+ actors with components: 60 FPS
- 10000+ sprites per frame: 60 FPS
- 100 physics bodies: 60 FPS with Box2D simulation
See CHANGELOG.md for planned features:
- v1.0 [RELEASED]: Core engine, physics, scripting, rendering
- v1.1 [Planned]: Particle system, tilemaps, animations
- v1.2 [Planned]: Level editor, prefabs, asset pipeline
- v2.0 [Future]: ECS architecture, multi-threading
This project is licensed under the MIT License. See the LICENSE file for details.
You are free to use FR-Ocean Engine for commercial projects, personal projects, educational purposes, and modification/distribution.
Contributions are welcome. Please see CONTRIBUTING.md for guidelines.
Ways to contribute:
- Report bugs and issues
- Suggest new features
- Improve documentation
- Submit bug fixes
- Add new features
- Create example games
Look for the good-first-issue label on GitHub for beginner-friendly tasks.
This engine utilizes the following open-source libraries:
- SDL2 - Simple DirectMedia Layer
- Box2D - 2D physics engine
- Lua - Scripting language
- LuaBridge - C++ to Lua binding
- GLM - Mathematics library
- RapidJSON - JSON parser/generator
- GitHub Issues: Report bugs or request features
- Discussions: Ask questions and share ideas
- Email: jackgaff@umich.edu
FR-Ocean Engine - Built by Jack Gaffney