Skip to content

RLNET Project Setup

Chris3606 edited this page Jan 13, 2018 · 6 revisions

Many of the explanatory documentation articles on this Wiki use the console library RLNET for display. The library is a NuGet package, and as such is easily able to be added to a project. The RLNET version on NuGet is slightly out of date compared to the repository, however is the feature changes mostly pertain to internals, and compiling the library from the repository is out of scope of this documentation. Furthermore, although it is possible to recompile RLNET to work with a .NET Core project, the version on NuGet works only for Mono/.NET Framework Projects. As such, it is assumed you are using a .NET Framework/Mono project for purposes of the Wiki examples.

For your convenience, a project that should compile on any .NET Framework/Mono-capable platform is provided here. However, should you wish to assemble the project yourself, instructions on how to do so are given below.

Creating the Project and Adding RLNET

The process is virtually identical to that for installing the GoRogue NuGet package. To install RLNET and setup the project used for the demo code on other pages on this wiki, follow the .NET Framework project setup instructions for your platform on the Getting Started page, naming the project GoRogue-Demo. Then, perform the following steps according to platform:

Platforms

Windows

  1. In Visual Studio, right-click the project in Solution Explorer, and select Manage Nuget Packages.

  1. Ensure that the Browse tab is selected, and that Package Source is set to nuget.org, then search RLNET. Install the package.

  1. RLNET requires a bitmap font file, and as such we need to add one to the project. The following image is the default font given with the RLNET Sample, and the one we will use. Save the following image (Right-Click->Save Image As or similar, depending on browser) as terminal8x8.png.

  1. Place the font file in the root of the project directory (the same location as Program.cs).

  1. RLNET will expect the font file to be in the same directory as the built executable. Thus, we must add the font file to the project, and instruct Visual Studio to copy the font file to the output directory on build. Right-Click the project in the solution explorer, and choose Add->Existing Item....

  1. From the dropdown beside the file name window, ensure All Files(.) is selected. Choose the terminal8x8.png file in the project directory, and click Add.

  1. Click the terminal8x8.png file in the Solution Explorer, and from the Copy to Output Directory dropdown in the Properties window, choose Copy if newer.

  1. Proceed with adding test code.

Linux

  1. In MonoDevelop, under the project dropdown, right-click on Packages, and choose Add Packages....

  1. Ensure that the Package Source dropdown is set to nuget.org, then search RLNET. Install the package.

  1. RLNET requires a bitmap font file, and as such we need to add one to the project. The following image is the default font given with the RLNET Sample, and the one we will use. Save the following image (Right-Click->Save Image As or similar, depending on browser) as terminal8x8.png.

  1. Place the font file in the root of the project directory (the same location as Program.cs).

  1. RLNET will expect the font file to be in the same directory as the built executable. Thus, we must add the font file to the project, and instruct MonoDevelop to copy the font file to the output directory on build. Right-Click the project in the solution explorer, and choose Add->Add Files....

  1. Choose the terminal8x8.png file in the project directory, and click Open.

  1. Right-click the terminal8x8.png file in the Solution Explorer, and select properties. In the Properties window, from the Copy to Output Directory dropdown, choose Copy if newer.

  1. Finally, we will change the default namespace to GoRogue_Demo. While not strictly required, all demonstration code on this Wiki uses GoRogue_Demo as the default namespace, so changing the project's to match will prevent the need to change the namespace in that code.

    • Right-click the Project in the solution explorer, and choose Options.

    • Under General->Main Settings, change the text in the Default Namespace: field to GoRogue_Demo. Press OK.

  2. Proceed with adding test code.

Mac

  1. In Visual Studio, under the project dropdown, right-click on Packages, and choose Add Packages....

  1. Ensure that the Package Source dropdown is set to nuget.org, then search RLNET. Install the package.

  1. RLNET requires a bitmap font file, and as such we need to add one to the project. The following image is the default font given with the RLNET Sample, and the one we will use. Save the following image (Right-Click->Save Image As or similar, depending on browser) as terminal8x8.png.

  1. Place the font file in the root of the project directory (the same location as Program.cs).

  1. RLNET will expect the font file to be in the same directory as the built executable. Thus, we must add the font file to the project, and instruct Visual Studio to copy the font file to the output directory on build. Right-Click the project in the solution explorer, and choose Add->Add Files....

  1. Choose the terminal8x8.png file in the project directory, and click Open.

  1. Right-click the terminal8x8.png file in the Solution Explorer, and select properties. In the Properties window, from the Copy to Output Directory dropdown, choose Copy if newer.

  1. Finally, we will change the default namespace to GoRogue_Demo. While not strictly required, all demonstration code on this Wiki uses GoRogue_Demo as the default namespace, so changing the project's to match will prevent the need to change the namespace in that code.

    • Right-click the Project in the solution explorer, and choose Options.

    • Under General->Main Settings, change the text in the Default Namespace: field to GoRogue_Demo. Press OK.

  2. Proceed with adding test code.

Adding Test Code

Replace the contents of the Program.cs file with the code below. This code is the basic RLNET setup used in the demonstrations, and serves to test that both RLNET and GoRogue are installed properly.

using GoRogue;
using RLNET;

namespace GoRogue_Demo
{
    class Program
    {
        // Initialize "root console" -- the main window of the game.
        public static RLRootConsole RootConsole = new RLRootConsole("terminal8x8.png", 50, 50, 8, 8, 1f, "GoRogue Demo");

        static void Main(string[] args)
        {
            // The root console's Update event is triggered once per frame,
            // followed by the root console's Render event.  Here, we add the
            // functions we would like to run upon each of those events happening.
            RootConsole.Update += rootConsole_Update;
            RootConsole.Render += rootConsole_Render;

            // Start the main window.
            RootConsole.Run();
        }

        static void rootConsole_Update(object sender, UpdateEventArgs e)
        {
            //Update Logic Here
        }

        static void rootConsole_Render(object sender, UpdateEventArgs e)
        {
            RootConsole.Clear();
            // Test GoRogue
            Coord c = Coord.Get(1, 1);
            RootConsole.Print(c.X, c.Y, "Hello World!", RLColor.White);
            RootConsole.Draw();
        }

    }
}

Finally, run the project. You should see the console window open, and "Hello World!" Be printed on the screen:

For additional details about RLNET and RLNET usage, see the RLNET bitbucket repository.