How ikemen-engine/ikemen-go works
1. What this repository is
Ikemen GO is a single Go-based game engine for 2D fighting games, designed to load and run M.U.G.E.N-style content. The repo is split between the engine code in src/, bundled default game data in data/, runtime scripts and assets in external/, and build/release tooling under build/ and .github/.
2. Runtime entry point and core orchestration
The executable starts from src/main.go, then hands control to the central engine/runtime layer in src/system.go and src/fightscreen.go. These files likely own the main loop, screen/state switching, match flow, and coordination between input, simulation, audio, rendering, and scripting.
3. Data-driven gameplay/content boundary
Most game behavior is not hardcoded; it comes from content files in data/ such as .cmd, .air, .cns, .zss, and .const. This points to a strong separation between engine code and game rules/assets: the engine interprets content describing characters, common fight logic, stages, training/demo behavior, scoring, and tag/guard-break systems.
4. Script compilation and bytecode layer
The files src/compiler.go, src/compiler_functions.go, src/bytecode.go, and src/script.go indicate a custom scripting pipeline. Script/source files from the content layer are compiled into an internal bytecode format, which the runtime executes to drive gameplay logic, UI behavior, and possibly stage/storyboard events.
5. Match simulation and state management
Core gameplay state appears to live in src/state.go, src/state_clone.go, src/char.go, src/stage.go, src/camera.go, src/anim.go, src/model.go, and src/stats.go. These subsystems likely model fighters, stages, animations, camera framing, per-frame state updates, cloning for rollback/replay, and match statistics.
6. Input, determinism, rollback, and netplay
The engine has explicit networking and rollback support in src/netplay.go and src/rollback.go, with input handled by src/input.go and src/input_sdl.go. Architecturally, this suggests a deterministic simulation core that can be rewound/resimulated for online play or latency hiding, with local input feeding the same state machine used in offline matches.
7. Rendering pipeline and backend abstraction
Rendering is abstracted behind multiple backend implementations: src/render.go with render_gl33.go, render_gles32.go, and render_vk.go. That means the engine supports OpenGL 3.3, OpenGL ES 3.2, and Vulkan through a shared rendering interface, with shaders stored in src/shaders/ and additional packaged effects in external/shaders/.
8. Font and text rendering
Text rendering is treated as a separate subsystem via src/font.go and backend-specific font implementations (font_gl33.go, font_gles32.go, font_vk.go). Bundled font assets in font/ plus shader assets under src/shaders/ suggest UI text and debug text are rendered through the same graphics pipeline as the rest of the game.
9. Audio and media
Audio is isolated in src/sound.go, src/audio_sdl.go, src/music.go, and src/sound_xm.go. The presence of src/video_ffmpeg.go shows the engine also integrates FFmpeg for video playback or cutscene-style media. SDL is used for the platform audio layer.
10. Platform and OS abstraction
Cross-platform support is organized through OS-specific utilities such as src/util_windows.go, src/util_linux.go, src/util_darwin.go, src/util_android.go, plus src/util_desktop.go and src/util_raw.go. There are also platform-specific support files like src/dllsearch_windows.go and src/stdout_windows.go, showing that platform integration is deliberately isolated from the engine core.
11. UI, menus, and scripted front-end
The external/script/ directory contains Lua scripts like main.lua, menu.lua, options.lua, start.lua, default.lua, and debug.lua. These likely drive the front-end/menu system and debug tooling separately from the fight simulation, giving the UI a scriptable layer distinct from the engine’s internal gameplay scripts.
12. Bundled default resources and skinning
src/resources/ contains default config/motif/storyboard INI files, while external/icons/ and font/ provide packaged assets. The README also notes the default screenpack/motif is externalized, so the engine itself is mostly content-agnostic and can be reskinned by swapping resource packs.
13. Build, packaging, and release pipeline
The repo includes Go module metadata (go.mod, go.sum), a Makefile, platform build scripts in build/, and Android Docker support under build/docker/android/. GitHub workflows handle linting, release automation, and wiki/script documentation generation, which supports a multi-platform release process rather than a single-target desktop app.
14. How the major flows connect
A typical flow is: startup loads config and packaged resources, scripts/content are compiled or interpreted, the main loop processes input, updates the deterministic fight state, optionally synchronizes via rollback/netplay, and renders/audio-playback are dispatched through the selected backend. The key architecture boundary is between the Go engine runtime and the external content packs that define characters, stages, UI, and game rules.
Main entry points: state.go State · fightscreen.go Fight Screen · system.go System · util_desktop.go Platform Utils
Components 21
Runtime Core
Main executable, match loop, simulation, rollback, and gameplay state.
- Main · Process entry that initializes the engine and hands off to the runtime.
src/main.go - System · Central orchestration for startup, mode switching, and frame flow.
src/system.go - Fight Screen · Fight-state controller coordinating simulation, input, and presentation.
src/fightscreen.go - State · Per-frame gameplay state and update logic for match execution.
src/state.go - State Clone · Cloning support for deterministic resimulation and rollback.
src/state_clone.go - Character · Fighter-side behavior, animation, and move/state integration.
src/char.go - Stage · Stage definition, interactions, and stage-specific runtime behavior.
src/stage.go - Camera · Match camera and framing logic used by gameplay and rendering.
src/camera.go - Animation · Animation playback and timing primitives used by fighters and stages.
src/anim.go
Content & Scripts
Data-driven fight content, front-end scripts, and bundled defaults.
- Compiler · Compiles content scripts into the engine's internal executable form.
src/compiler.go - Bytecode · Internal bytecode representation used by the script runtime.
src/bytecode.go - Script Runtime · Executes compiled scripts and exposes gameplay-facing script behavior.
src/script.go - Defaults · Bundled default config, motif, and storyboard resources.
src/resources/defaultConfig.ini - Game Data · Data-driven rules and content such as commands, states, and training logic.
data/common.cmd - Lua UI · Scripted menus, options, debug tools, and startup UI flow.
external/script/main.lua
Presentation & Media
Rendering, fonts, audio, video, and asset-backed UI presentation.
- Render API · Backend-agnostic rendering interface for the engine.
src/render.go - Font System · Text rendering and font integration across backends.
src/font.go - Sound · Audio playback, music, and sound effect coordination.
src/sound.go - Video · FFmpeg-backed media playback for video or cutscene content.
src/video_ffmpeg.go
Platform & Build
OS abstraction, packaging, release automation, and build tooling.
- Platform Utils · OS-specific utilities and desktop/platform integration points.
src/util_desktop.go - Build Tools · Scripts and workflows for builds, release, and documentation generation.
build/build.sh
Connections 20
- Main → System: starts · Entry point initializes the runtime orchestration layer.
- System → Fight Screen: switches to · System delegates match flow to the fight screen controller.
- Fight Screen → State: updates · Fight loop advances deterministic gameplay state each frame.
- State → State Clone: snapshots · State can be cloned for rollback and resimulation.
- State → Character: contains · Core state includes fighter logic and per-character updates.
- State → Stage: contains · Match state includes stage simulation and interactions.
- State → Camera: drives · Simulation influences camera framing and visibility.
- State → Animation: uses · Runtime state relies on animation timing and playback.
- Compiler → Bytecode: emits · Script sources are compiled into internal bytecode.
- Script Runtime → Bytecode: executes · Script runtime interprets compiled bytecode.
- Game Data → Compiler: feeds · Content files provide the rule data consumed by compilation/runtime.
- Defaults → System: bootstraps · Packaged defaults seed startup configuration and UI assets.
- Lua UI → System: controls · Lua front-end scripts drive menus and startup navigation.
- Fight Screen → Render API: draws via · Match screen renders through the graphics abstraction.
- Fight Screen → Sound: plays via · Match screen routes audio and music through the sound subsystem.
- Render API → Font System: includes · Text rendering is layered on top of the graphics backend.
- Render API → Platform Utils: depends on · Rendering and windowing rely on platform utilities.
- Sound → Platform Utils: depends on · Audio and media integration use OS-specific support layers.
- Video → Platform Utils: depends on · Video playback integrates with the platform layer.
- Build Tools → Platform Utils: targets · Build and release tooling targets multiple operating systems.