How kennycason/kengine works
Main Components
• Core Engine – Represented by the “kengine” directory, which houses the game engine’s core features. This includes multiple subsystems such as:
– Graphics (rendering, sprite management, animated sprites, textures, geometry)
– Input (keyboard, mouse, controller)
– Audio and Sound (synth, sound context, audio assets)
– Physics (integration with Chipmunk2D)
– Math utilities (vector, rectangle, etc.)
– Utility Hooks & Contexts (useState, useEffect, useMemo, useReducer, Context management)
– Event Handling and Logging
– Native interop and SDL3 support
• Example Games – Under “games” you have several demo/game projects (e.g., boxxle, helloworld, image-shuffle, osc3x-synth, physics-demo). Each game leverages the engine’s APIs and follows a structure with its own assets, source code (under nativeMain), and build scripts.
• Build and Plugin Infrastructure – The “buildSrc” folder contains Gradle build logic along with custom Kotlin plugins (e.g., asset copier plugins, native plugins) that help manage asset pipelines and module configurations for the overall project.
• Testing Framework – The “kengine-test” module provides integration/unit tests for the engine, covering core functionality in graphics, events, hooks, networking, input, etc.
• Platform Specifics – There is a dedicated “kengine-playdate” subproject for targeting the Playdate platform with its own native code and build integration.
Relationship and Interactions
• The Core Engine (kengine) forms the backbone; it provides the API and runtime contexts that the games depend on.
• The build system (Gradle with buildSrc plugins) manages dependency injection, asset processing (copying assets, DLL handling as seen with SDL and native plugins), and builds across multiple modules.
• Tests in kengine-test validate the core subsystems ensuring proper function and performance.
• The integration with SDL3 and other native libraries (visible in the “sdl3” folder and cinterop directories) are represented as external services or platform dependencies that the engine wraps.
Architectural Patterns and Design Principles
• Modularity: The engine is divided into clearly separated packages and domains (graphics, input, physics, etc.) to ease maintenance and testability.
• Layered Approach: The core engine sits below the game-specific code, providing shared functionality and abstraction over native libraries.
• Build-Time Plugins: Custom Gradle plugins in buildSrc indicate a build-time mechanism to perform tasks (like asset copying and configuration) that influence run-time behavior.
Relevant Technologies and Libraries
• Kotlin Native – Primary language and platform.
• SDL3 – For rendering, input handling, and media operations.
• Chipmunk2D – Physics engine support.
• Gradle – Build tool, with Kotlin DSL scripts.
• Custom libraries and hooks for state and event management.