Skip to content

jack-chaudier/fr-ocean-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FR-Ocean Engine

A professional 2D game engine built with C++17 and Lua scripting.

C++17 Lua 5.4 Platform License Version

Overview

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.

Key Features

  • 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

Features

Core Engine

  • 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

Rendering

  • 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

Physics

  • 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

Audio

  • 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

Scripting

  • 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

Developer Tools

  • 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

Requirements

Windows

  • Visual Studio 2019 or newer
  • CMake 3.16+

macOS

  • Xcode 12+ or Command Line Tools
  • CMake 3.16+

Linux

  • GCC 9+ or Clang 9+
  • CMake 3.16+
  • SDL2, SDL2_image, SDL2_mixer, SDL2_ttf development packages

Installation

Building from Source

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 Release

macOS:

git clone https://github.com/jackgaff/fr-ocean-engine.git
cd fr-ocean-engine
mkdir build && cd build
cmake ..
cmake --build . --config Release

For 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 ..
make

The executable outputs to build/bin/game_engine with resources copied to build/bin/resources/.

Command-Line Options

./game_engine [options]

Options:
  --resources <path>  Override resources directory (default: resources/)
  --debug             Enable debug logging
  --version           Print version and exit
  --help              Print help message

Usage

Creating a Lua Component

-- 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)
end

Project Structure

fr-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

Documentation

Example Games

The engine includes three example games to demonstrate different capabilities:

Space Shooter (resources.example/)

  • Player movement and shooting
  • Enemy spawning and AI
  • Collision detection with triggers
  • Score tracking and game over state

Platformer (resources.platformer/)

  • 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/

Puzzle Match (resources.puzzle/)

  • 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/

Troubleshooting

"error: resources/ missing"

Ensure you have a resources/ directory containing game.config and rendering.config.

"error: font X missing"

Font files must be placed in resources/fonts/ with .ttf extension.

SDL initialization failed

  • 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

Lua component not loading

  • 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

Performance

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

Roadmap

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

License

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.

Contributing

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.

Credits

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

Community


FR-Ocean Engine - Built by Jack Gaffney

Star on GitHub | Fork | Contribute

About

Miniature 2D Game Engine

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors