How emmachase/riko4 works
Based on your file tree and README, Riko4 is a fantasy computer and game engine with a dual-layer architecture. Essentially, you have a core engine written in C/C++ (found under the “src” directory) that handles low-level functionality like audio, graphics (GPU, shader management), file system operations, networking, and more. On top of that, you have a rich scripting layer (mostly Lua) located throughout the “scripts” directory. This layer provides everything from bootstrapping (boot.lua) to a variety of interactive demos, games, and even a built-in shell (scripts/usr) that mimics an operating system environment. In addition, assets and data (like shaders in the “data” folder) are also parts of the system that the engine consumes at runtime.
Main Components
• Core Engine (C++):
• Represented by the “src” folder that includes several modules:
• Core: Handles events, Lua machine integration, process management, and shader management.
• Engine: Contains submodules for audio, file system (fs), GPU image processing, networking, polygons handling, timer functions, and userdata management.
• Scripting Layer (Lua):
• Found in the “scripts” folder and its subdirectories:
• Boot and initialization scripts.
• Game demos and interactive applications (located in “scripts/home/demos” and “scripts/home/games”) that showcase various features of the engine.
• User-facing shell and utilities (under “scripts/usr”) offering command-line functionality and editors.
• Reusable libraries (in “scripts/lib”) that extend capabilities of the engine such as bitmap manipulation, UI components, and event mediation.
• Data/Assets:
• The “data” directory, especially the shaders (common.frag, common.vert), which are utilized by the engine’s shader subsystem.
• Build and Dependency Management:
• CMake configuration files (CMakeLists.txt, CMakePresets.json) and vcpkg configuration (vcpkg.json and vcpkg-overlay) illustrate the external libraries (such as SDL and sdl-gpu) that are integral to the project.
Component Interactions
• A layered relationship where the C++ Core Engine forms the bottom layer that interacts directly with hardware or system APIs. The engine exposes APIs (for graphics, audio, input, etc.) that the Lua scripting environment can invoke.
• That the Lua layer sits on top, using an embedded Lua interpreter (as instantiated by luaMachine.cpp in the “src/core” folder) to execute scripts, drive game demos, expose shell commands, and manage user interactions.
• That assets (e.g., shaders, game resources) flow from the “data” folder into the engine at runtime.
Architectural Patterns and Design Principles
• Separation of concerns between the engine (system-level operations) and the scripting layer (high-level logic, demos, user interface).
• That the project follows a modular design: core engine modules are clearly separated (e.g., “audio”, “gpu”, “net”) and the scripting libraries are bundled in dedicated folders.
• Mention integration through language binding (C++ to Lua) that illustrates an interpreter or bridge design pattern.
• Plugin/extensibility design observed in “scripts/lib” which can be enhanced or extended with additional Lua modules.
Relevant Technologies
• C/C++ as the implementation language (with files in “src”).
• Lua for scripting the high-level behaviors (scripts, demos, shell commands).
• CMake for build automation, with integration to vcpkg to manage third-party libraries such as SDL and specialized ports (e.g., sdl-gpu).
• Use of shader technology (GLSL) as indicated by “common.frag” and “common.vert” for graphical rendering.
Being Detailed
• Don’t hesitate to break down the “Core Engine” into its submodules (e.g., events, graphics, audio, network) and similarly detail the various Lua script groupings such as demos, games, and user tools.