Getting Started with Nu - bryanedds/Nu GitHub Wiki

Follow these steps to create your own Nu project from the Game project template -

  1. Install Git - https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

  2. Install .NET 9.

  3. Fork Nu to your github account (sign up if you don't have one) - https://github.com/bryanedds/Nu/fork

  4. Clone your fork of Nu via git's clone command to your local machine, or if you didn't fork in the previous step, clone Nu via https://github.com/bryanedds/Nu.git

  5. Install an IDE such as Visual Studio 2022, Visual Studio Code, or JetBrains Rider. Make sure to opt-in to installing any components related to developing with F#. If you don't install Visual Studio, you will need to install latest vcredist such as from - https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

  6. If you're on Linux, install the OS-level dependencies by running the Configure.Linux.Development.sh shell script found in Nu's root folder.

  7. Open up Nu.sln from the cloned repo with your chosen editor. In Visual Studio 2022, you'll see a view similar to this -

image

  1. Expand the Nu folder and, if you're using Visual Studio, right-click the Nu.Gaia project in the Solution Explorer and select, Set as Startup Project.

  2. On Linux, you might also run into the following issue when running Nu - Unhandled exception. System.TypeInitializationException: The type initializer for 'OpenGL.Egl' threw an exception. Unable to load shared library 'dl' or one of its dependencies. There is a known solution for most Linux systems here - https://github.com/bryanedds/Nu/issues/590

  3. Build the solution and Run the Nu.Gaia project, such as by hitting the F5 key in Visual Studio. If it gets stuck on building in Visual Studio, you may have to restart Visual Studio to get it to build the first time due to a bug in its build infrastructure (F# tooling isn't yet completely mature just yet, but otherwise pretty good). You will see a screen like this -

image

  1. Create a new Nu project that uses the default Nu project template by opening the Game dropdown menu, and then clicking New Project. You will see a project creation dialog like so -

image

  1. Give your Nu game project a valid name. For this example, we'll stick with the default new project name, My Game using the MMCC Game project. Creating the project will shut down the editor and allow you to run the Nu.Gaia editor with the new project loaded for editing.

  2. If using Visual Studio, you will be prompted to reload the solution with the newly-created project. Confirm this request.

  3. Expand the Projects folder and you will see your new project in the IDE -

image

  1. Build the solution and Run Nu.Gaia again, such as by hitting F5 in Visual Studio. You will see the new game opened for editing in Nu.Gaia -

image

  1. By clicking the Mode dropdown on the menu, you can select which part of the game to edit -

image

  1. Let's click on Gameplay to edit the demo gameplay level. You will see the following -

image

  1. On the left side, you will see the editable entity hierarchy. At the top is the Group selection dropdown. In Nu, each game is composed of screens (you've already seen the Title screen and now you're in the Gameplay screen). And each Screen, such as this Gameplay screen, is composed of Groups. In Nu, a Group is just a collection of related Entities, similar to what's known as a 'Scene' in other game engines like Unity. You can use Groups to organize the entities in your screen as you see fit. Click the Group selection dropdown like so and you can see the other Group available for editing, Scene. Select that group now.

image

  1. Here you see a mostly empty 3D scene with three entities. You can move the view around as needed with WASD and arrow keys. Click to select objects and drag them to change their position.

  2. Now hit F5 in the editor to run the game like so -

image

  1. The only thing you'll see happening is the StaticModel rotating. Again, this is mostly an empty project.

  2. If you edited the Scene in any way, you can save it by hitting Ctrl+S, then navigating to the Assets folder, then the Gameplay folder, clicking Scene.nugroup, then clicking Save like so -

image

When you leave the Gameplay screen (or editor), the entities in that group will be as you left them.

To learn more about how to actually start building a game in MMCC, please refer to the existing demo game project available in the solution, going from smallest to biggest, Nelmish, Breakout MMCC, then Terra Firma. Be sure to read the MMCC tutorial here first, tho - https://github.com/bryanedds/Nu/wiki/Model-View-Update-for-Games-via-MMCC

To learn more about building a game in ImNui, check out Jump Box then Breakout ImNui. Read the ImNui tutorial here - https://github.com/bryanedds/Nu/wiki/Immediate-Mode-for-Games-via-ImNui