How nmvteam/nightmarevision works
1. This repository is a Haxe-based rhythm game engine, built on the Funkin/Psych Engine lineage. The runtime stack is centered on HaxeFlixel with Lime/OpenFL and hxcpp for native desktop builds. The README also shows a strict local dependency workflow via hxpkg/hmm, which is part of the build architecture.
2. The application entry path is small and bootstraps into the game framework: Main.hx, Init.hx, and Splash.hx lead into the engine’s main game object and state system. From there, source/funkin/backend/FunkinGame.hx and related backend classes coordinate startup, scaling, input, logging, crash handling, and transitions.
3. The engine is organized around a state machine. The main user-facing flow is TitleState -> MainMenuState -> StoryMenuState / FreeplayState / ModsState / OptionsState -> PlayState, with dedicated substates for pause, game over, prompts, resets, and gameplay modifiers. This is the primary navigation and screen architecture to diagram.
4. Actual gameplay is concentrated in PlayState and the objects/note and game/huds packages. Notes, strums, sustains, splashes, countdown, rating logic, and HUD rendering are separate components, with the Conductor handling song timing and beat/step synchronization. This is the core real-time loop of the engine.
5. Game content is data-driven. Runtime definitions come from files under assets/game/data such as characters, stages, weeks, song metadata, note skins, intro text, and high scores/prefs-backed data models in source/funkin/data. The architecture expects content to be swapped or extended via these external data files rather than hardcoded scenes.
6. Visual presentation is split into reusable objects and stage-specific actors. Core objects like Character, Stage, BGSprite, MenuItem, Alphabet, and HealthIcon are shared across screens, while stage decorations and special animated characters live under objects/stageobjects and the assets/game/images sprite/XML sets.
7. Audio is a first-class subsystem. Music, SFX, sound trays, intro/game-over tracks, and song stems live in the asset tree, while code in source/funkin/audio and source/funkin/audio/visualize handles playback wrappers, synchronized sound groups, waveform data, and spectrum/FFT visualization. This supports both gameplay timing and UI/audio feedback.
8. Modding and scripting are a major architectural boundary. source/funkin/scripting, source/funkin/scripts, and source/extensions/hscript support scripted states, substates, and extensible logic, while source/funkin/game/modchart implements the note-modifier/event timeline system. This layer is where custom gameplay effects and chart-driven transformations plug into the core engine.
9. The codebase includes a substantial editor subsystem, not just a game runtime. Editor states for charts, characters, song metadata, weeks, and note skins live under source/funkin/states/editors, with shared UI kits underneath. The assets/excluded tree suggests optional editor-only UI resources that are kept separate from standard gameplay assets.
10. Platform and tooling integrations matter here. There are extensions for Discord presence, fullscreen, hot reload, enhanced camera/sound/UI behavior, plus native memory and HL-specific fixes. Macros and utility code in source/funkin/backend/macro and source/hl indicate compile-time and target-specific support is part of the architecture, not an afterthought.
11. Asset layout is deliberately partitioned by purpose: assets/embeds for bundled media, assets/game for core runtime content, and assets/excluded for non-shipped/editor assets. This separation is important for understanding what is embedded at build time versus what is treated as game content the engine loads from disk.
12. Overall, the repository is best diagrammed as a layered engine: bootstrap/runtime core at the bottom, a data-driven gameplay state machine in the middle, and optional scripting/editing/modding systems layered on top. The main external boundaries are the filesystem asset packs, compiled native libraries, and any runtime integrations like Discord or profiling.
Main entry points: PlayState.hx PlayState · data Game data · states State flow · backend Backend core
Components 21
Bootstrap & runtime
Entry points, engine bootstrap, and platform/runtime integration.
- Main · Application entry that starts the Haxe runtime.
source/Main.hx - Init · Early initialization and startup wiring.
source/Init.hx - Splash · Splash/loading state before the main game framework.
source/Splash.hx - FunkinGame · Main game object coordinating boot, scaling, input, logging, and transitions.
source/funkin/backend/FunkinGame.hx - Backend core · Conductor, controls, crash handling, cache, input, logging, and transition support.
source/funkin/backend - Platform plugins · Discord, fullscreen, hot reload, camera/sound/UI extensions, and target-specific fixes.
source/funkin/backend/plugins
Gameplay engine
Core state machine, gameplay loop, HUD, and note systems.
- State flow · Top-level menu and gameplay navigation states.
source/funkin/states - PlayState · Primary real-time song and chart gameplay loop.
source/funkin/states/PlayState.hx - Menu states · Title, main menu, story, freeplay, mods, options, and credits screens.
source/funkin/states - Substates · Pause, game over, prompts, reset score, and gameplay changer overlays.
source/funkin/states/substates - HUD · Gameplay heads-up display and score/rating presentation.
source/funkin/game/huds - Note system · Notes, strums, sustains, splashes, and playfield behavior.
source/funkin/objects/note - Conductor · Song timing, beat/step synchronization, and gameplay clocking.
source/funkin/backend/Conductor.hx
Data & assets
Externalized game content and asset partitions.
- Game data · Character, song, chart, stage, week, skin, prefs, and metadata models.
source/funkin/data - Game assets · Primary shipped content: characters, stages, songs, UI sprites, music, and sounds.
assets/game - Embedded assets · Packaged media included at build time.
assets/embeds - Excluded assets · Editor-only or non-shipped resources separated from runtime content.
assets/excluded
Scripting & modding
Script execution, modifiers, and extension boundaries.
- Scripting layer · Scripted states, substates, plugin management, and script runtime helpers.
source/funkin/scripting - Modchart · Note modifiers, event timelines, and chart-driven transformations.
source/funkin/game/modchart
Connections 25
- Main → Init: boots · Entry hands off to initialization.
- Init → Splash: loads · Startup flow continues through splash/loading.
- Splash → FunkinGame: starts · Splash transitions into the main engine object.
- FunkinGame → Backend core: uses · Game object relies on backend services for runtime coordination.
- Backend core → Conductor: syncs · Backend timing drives beat/step logic.
- Backend core → Platform plugins: extends · Runtime plugins add platform and UX integrations.
- FunkinGame → State flow: drives · Core game object owns the active state machine.
- State flow → Menu states: navigates · Menu/state navigation covers title and selection screens.
- State flow → PlayState: enters · Gameplay state is the main destination from menus.
- State flow → Substates: overlays · Transient overlays branch off the primary state flow.
- PlayState → Note system: renders · Play state instantiates and updates playfield notes.
- PlayState → HUD: shows · Gameplay overlays are rendered through the HUD layer.
- PlayState → Conductor: consumes · Play state uses song timing and synchronization.
- PlayState → Game data: loads · Gameplay content is resolved from data models.
- Game data → Game assets: maps to · Runtime data points to disk-backed game content.
- Game data → Embedded assets: bundles · Some content ships as embedded media.
- Editors → Game data: edits · Editors author the same underlying game data models.
- Editors → Editor UI: shares · Editor screens reuse common UI toolkits.
- Editors → Excluded assets: uses · Editor-only resources are kept separate from shipped assets.
- Scripting layer → PlayState: augments · Scripts can alter runtime behavior and states.
- Scripting layer → Substates: injects · Scripted substates and overlays hook into the state machine.
- Scripting layer → Modchart: configures · Modding layer powers chart modifiers and event timelines.
- Modchart → Note system: affects · Modifiers reshape note and receptor behavior.
- Game assets → Game data: contains · Game content directories store the authoritative runtime files.
- Embedded assets → Backend core: supplies · Bundled media and sounds support startup and UI/runtime feedback.