Getting Started with Nu - bryanedds/Nu GitHub Wiki
Follow these steps to create your own Nu project from the Game project template -
-
Install Git - https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
-
Install .NET 9.
-
Fork Nu to your github account (sign up if you don't have one) - https://github.com/bryanedds/Nu/fork
-
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 -
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
-
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. -
Open up
Nu.sln
from the cloned repo with your chosen editor. In Visual Studio 2022, you'll see a view similar to this -
-
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
. -
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 -
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 -
- 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 -
-
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. -
If using Visual Studio, you will be prompted to reload the solution with the newly-created project. Confirm this request.
-
Expand the Projects folder and you will see your new project in the IDE -
- 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 -
- By clicking the Mode dropdown on the menu, you can select which part of the game to edit -
- Let's click on Gameplay to edit the demo gameplay level. You will see the following -
- 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.
-
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.
-
Now hit F5 in the editor to run the game like so -
-
The only thing you'll see happening is the StaticModel rotating. Again, this is mostly an empty project.
-
If you edited the Scene in any way, you can save it by hitting Ctrl+S, then navigating to the
Assets
folder, then theGameplay
folder, clickingScene.nugroup
, then clickingSave
like so -
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