Friday Night Funkin'

repository·main·Indexed 25 days ago

https://github.com/funkincrew/funkin

A rhythm game built using HaxeFlixel. This documentation covers compiling the game from source for Desktop, Android, and iOS, modding capabilities including asset replacement and scripted classes via modding.base, and technical details on the json2object parsing system, JSFL scripting, and the HTML5 preloader architecture.

Tokens
8.5K
Snippets
11
Records
64
Agent score
84%

What's inside funkin

  1. Overview of funkin.ui.loading.preload

    main

    The funkin.ui.loading.preload package powers the HTML5 preloader screen. It is responsible for preparing the game environment by downloading, caching, and parsing essential assets and scripts.

    Note: This preloader is specifically designed for HTML5. It is not used on desktop platforms; desktop versions use the splash loader instead because of how Lime handles asset loading compared to HaxeFlixel.

  2. Understand the .fnfc file format structure

    main

    An .fnfc file is a standard ZIP archive used to store all assets required for a Friday Night Funkin' level, including audio, metadata, and chart data. This format supports "variations"—groups of difficulties that share gameplay data (like Normal and Hard) or use different assets (like special music or characters).

    Core File Components:

    • manifest.json: Essential for parsing the chart.
    • Inst.ogg: Mandatory instrumental track for the default variation.
    • <songid>-metadata.json: Metadata for the default variation (song name, artist, BPM, etc.).
    • <songid>-chart.json: Note and event data for the default variation.
    • Voices-<charid>.ogg: Optional character vocal tracks.
    • Inst-<instid>.ogg: Optional alternative instrumental tracks.
    • <songid>-metadata-<variation>.json: Optional metadata for alternate variations.
    • <songid>-chart-<variation>.json: Optional chart data for alternate variations.
  3. Document public functions with JavaDoc-style comments

    main

    Use JavaDoc-style code comments for public functions to ensure clarity. It is recommended to use the CodeDox extension for VSCode to support this. Comments should include descriptions for parameters and return values.

    /**
     * Finds the largest deviation from the desired time inside this VoicesGroup.
     *
     * @param targetTime	The time to check against.
     * 					If none is provided, it checks the time of all members against the first member of this VoicesGroup.
     * @return The largest deviation from the target time found.
     */
    public function checkSyncError(?targetTime:Float):Float
  4. Choose the correct base branch for Pull Requests

    main

    When creating a branch in your fork, select the base branch based on the files you are modifying:

    • develop branch: Use this if you are modifying game code (.hx files) or any other non-documentation file. When in doubt, use develop.
    • main branch: Use this only if you are modifying documentation (.md files) or GitHub configuration files (.yml files or anything in the .github folder).

    Important: Do not use your fork's default main branch for your PR. Instead, create a dedicated branch for your changes (e.g., docs/fix-typo or minor-bugfix).

  5. Use debug hotkeys available in any state

    main

    The following hotkeys are available regardless of the current game state. Note that most of these require a debug build of the game to function.

    • INSERT: Perform immediate memory garbage collection.
    • F2: Enable the Flixel debug overlay (supports partial scripting).
    • F3: Take a screenshot and save it to the local screenshots directory. (Works in non-debug builds).
    • F4: Forcibly switch to the Main Menu without transitions.
    • F5: Hot reload scripts and data files, then restart the current state. This processes changes to files in the assets folder. Note: This may not reset song charts or song scripts due to a known bug, but will reset stage layout and character animation data.
    • CTRL-ALT-SHIFT-L: Force a crash with a detailed crash log and stack trace.
  6. Format JSON files with Prettier

    main

    JSON formatting is handled by the esbenp.prettier-vscode extension (Prettier). Configuration is managed via a .prettierrc.js file.

    Formatting Behavior:

    • Prettier attempts to place expressions on a single line if they fit.
    • If an object is manually formatted as multi-line, Prettier will keep it multi-line.
    • To force Prettier to collapse a short multi-line object into a single line, you may need to use regex replacement to remove the first newline in the object.
  7. Compile Friday Night Funkin' for macOS (Android Target)

    main

    To build an Android version of the game on macOS:

    Setup Steps

    1. Create a dedicated folder for Android tools.
    2. In your terminal, set the environment variables:
      • ANDROID_HOME to your folder path.
      • Update your PATH to include $ANDROID_HOME/cmdline-tools, $ANDROID_HOME/cmdline-tools/bin, and $ANDROID_HOME/platform-tools.
    3. Download Android Studio Command-line Tools and extract them into your folder.
    4. Install the required SDK components using sdkmanager:
      • build-tools;35.0.0
      • ndk;29.0.13113456
      • platforms;android-29
      • platforms;android-35
    5. Install JDK 17 for macOS.
    6. Run lime setup android and provide the following paths when prompted:
      • Android SDK: Your tools folder path.
      • Android NDK: [your-folder]/ndk/28.0.13004108 (Note: Check documentation for specific version requirements).
      • JDK: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home (If not prompted, you can skip this).

    Build Command

    Run the following to build and test on Android:

    lime test android
    export ANDROID_HOME=/path/to/your/folder
    export PATH=$PATH:$ANDROID_HOME/cmdline-tools:$ANDROID_HOME/cmdline-tools/bin:$ANDROID_HOME/platform-tools
    sdkmanager --install "build-tools;35.0.0" "ndk;29.0.13113456" "platforms;android-29" "platforms;android-35"
    lime setup android
    lime test android
  8. Requirements for reporting issues

    main

    Before reporting a bug or suggesting an enhancement, ensure you meet the following criteria to ensure the report is valid:

    1. Version: You must be playing the latest version of the game.
      • Android: v0.8.5
      • All other platforms: v0.8.4
    2. Environment: Play without any mods installed.
    3. Source: Use the official versions from Newgrounds or itch.io.
  9. Use modding.base to create scripted classes

    main
    The modding.base package provides base classes that modders can extend to create scripted classes. This allows for custom logic to be injected into the game via scripts. For example, you can create a script that extends FlxSprite and then instantiate it within the game using ScriptedFlxSprite.init('ClassName').
  10. Implement song variations in FNFC files

    main

    Variations allow a single song to have different gameplay experiences (e.g., different music or characters for 'Nightmare' mode) without duplicating everything.

    To implement variations:

    1. In the default variation's playData.songVariations array, include the IDs of the variations you want to support.
    2. For each variation ID (e.g., erect), provide the corresponding files in the ZIP:
      • <songid>-metadata-<variation>.json (Optional)
      • <songid>-chart-<variation>.json (Optional)
      • Voices-<charid>-<variation>.ogg (Optional)
    3. If a variation uses a different instrumental, specify it in the variation's metadata using playData.characters.instrumental.