osu! Game Engine

repository·master·Indexed 10 days ago

https://github.com/ppy/osu

Source code for the osu! game engine, providing a framework for developing custom rulesets and game logic. Includes documentation on building from source using .NET 8.0 SDK, creating custom rulesets via ppy.osu.Game.Templates, and implementing storyboard effects using IStoryboardCommand and StoryboardCommandGroup.

Tokens
6.8K
Snippets
20
Records
29
Agent score
97%

What's inside osu!

  1. Develop a custom osu! ruleset

    master

    osu! supports user-created gameplay variations called "rulesets". Developers can create new rulesets to use the existing osu! beatmap library, game engine, and UX for different gameplay styles.

    To start, use the templates provided in the repository: Templates directory.

  2. Create a new osu! ruleset using dotnet templates

    master

    Once the templates are installed, you can scaffold new ruleset projects using the dotnet new command. You can choose between empty templates for manual implementation or example templates that include working samples.

    # Create an empty freeform ruleset
    dotnet new ruleset -n MyCoolRuleset
    
    # Create an empty scrolling ruleset (provides basics for ←↑→↓ scrolling)
    dotnet new ruleset-scrolling -n MyCoolRuleset
    
    # Start with a working sample freeform game
    dotnet new ruleset-example -n MyCoolWorkingRuleset
    
    # Start with a working sample scrolling game
    dotnet new ruleset-scrolling-example -n MyCoolWorkingRuleset
  3. Test with local osu-framework or osu-resources modifications

    master

    If you are making changes to osu-framework or osu-resources and want to cross-test them within the osu repository, use the provided scripts.

    Requirement: These scripts assume the projects are checked out in adjacent directories:

    |- osu            // this repository
    |- osu-framework
    |- osu-resources

    Windows

    UseLocalFramework.ps1
    UseLocalResources.ps1

    macOS / Linux

    ./UseLocalFramework.sh
    ./UseLocalResources.sh
  4. Install the osu! templates package

    master

    To use the osu! project templates for creating custom rulesets, you must first install the ppy.osu.Game.Templates package using the dotnet CLI. This is a one-time setup step.

    dotnet new install ppy.osu.Game.Templates
  5. Build and run osu! from source

    master

    Using an IDE

    Load the solution using a platform-specific .slnf file to reduce dependencies and hide irrelevant platforms:

    • osu.Desktop.slnf (Recommended for most desktop development)
    • osu.Android.slnf
    • osu.iOS.slnf

    Use the IDE's built-in Build/Run functionality. For testing components, use the osu! (Tests) project/configuration.

    Using the CLI

    You can build and run the desktop version directly using the dotnet CLI:

    dotnet run --project osu.Desktop

    Important: When performing performance testing, always use the Release configuration to avoid the high overhead of Debug mode:

    dotnet run --project osu.Desktop -c Release

    If the build fails, attempt to restore packages with:

    dotnet restore
  6. Prerequisites for developing osu!

    master

    To build and develop osu! from source, you must have the following installed:

    • .NET 8.0 SDK

    Recommended IDEs:

    • Visual Studio (latest version)
    • JetBrains Rider
    • Visual Studio Code (with EditorConfig and C# Dev Kit plugins)

    Note: For mobile platform builds (Android/iOS), you may need to run sudo dotnet workload restore to install the necessary tooling.

  7. Format and analyze osu! code

    master

    Before committing code, ensure it follows the project's standards:

    • Formatting: Run dotnet format via CLI or use the Format code command in your IDE.
    • Static Analysis: The project uses cross-platform, compiler-integrated analyzers.
    • Advanced Analysis: Use JetBrains ReSharper InspectCode. You can run it via PowerShell using `.\
  8. Use StoryboardColourCommand to manipulate color

    master

    The StoryboardColourCommand is used within the osu! storyboard system to transition the Colour property of a Drawable over a specified time range. It applies an initial color at the startTime and transitions to an endValue at the endTime using a specified Easing function.

    When applied to a Drawable, it performs the following sequence:

    1. Sets the initial color to StartValue.
    2. Applies a color fade from StartValue to EndValue over the command's duration using the provided Easing.
    // Example instantiation of a StoryboardColourCommand
    // Parameters: Easing, startTime, endTime, startValue, endValue
    var command = new StoryboardColourCommand(
        Easing.Linear,
        0.0,
        2.0,
        new Color4(1, 0, 0, 1), // Red
        new Color4(0, 0, 1, 1)  // Blue
    );
  9. Use StoryboardScaleCommand to scale elements

    master

    The StoryboardScaleCommand is used within the osu! storyboard system to animate the Scale property of a Drawable. It transitions an element's scale from a startValue to an endValue over a specified time range using a given easing function.

    Behavior

    • Initial State: When the command is applied, the element's scale is immediately set to new Vector2(StartValue).
    • Animation: The command applies a transform sequence that scales the element to the StartValue (effectively ensuring the starting point) and then animates it to the EndValue over the command's duration using the specified Easing.

    Parameters

    • easing: The Easing function to use for the transition.
    • startTime: The time (in milliseconds) when the scale animation begins.
    • endTime: The time (in milliseconds) when the scale animation ends.
    • startValue: The initial scale multiplier (applied to both X and Y axes).
    • endValue: The final scale multiplier (applied to both X and Y axes).
    // Example instantiation of a scale command
    // Scales an element from 0.5 to 1.0 using Linear easing between 0 and 2000ms
    var scaleCommand = new StoryboardScaleCommand(
        Easing.Linear,
        0,
        2000,
        0.5f,
        1.0f
    );
  10. Use StoryboardFlipHCommand to flip elements horizontally

    master

    The StoryboardFlipHCommand is a storyboard command used to animate the horizontal flip state of a drawable that implements the IFlippable interface. It transitions the FlipH property from a startValue to an endValue over a specified duration.

    To use this command, you must provide an easing function, a start time, an end time, and the boolean values for the initial and final flip states.

    // Example instantiation of the command
    // Note: This is a constructor signature; actual usage depends on the Storyboard engine's orchestration
    new StoryboardFlipHCommand(
        easing: Easing.Linear,
        startTime: 0.0,
        endTime: 2.0,
        startValue: false,
        endValue: true
    );