Getting Started

Creating the Project
  1. First download the source or dll for RLNET here.
  2. In Visual Studio, create a new project. Select Empty Project under Visual C# / Windows.
  3. Right click the project and select Add Reference.. browse and add “RLNET.dll” and “OpenTK.dll”
  4. Right click the project and select Add then Existing Item. Locate “ascii_8x8.png” and add. Remember to set the Copy to Output Directory property of the png to Copy if newer.
  5. Right click the project and open the properties. On the application tab change the Output to Windows Application.
 Hello World!

Now to make sure RLNET is working correctly. Create a Program class. Add a using for the RLNET namespace.

using RLNET;

Then add a static variable for the root console.

public static RLRootConsole rootConsole;

In your main function, construct the root console.

rootConsole = new RLRootConsole("ascii_8x8.png", 60, 40, 8, 8);

The first parameter is the filepath to the png. The second and third are the width and height of the window in tiles. The fourth and fifth parameters are the width and height of the tiles in pixels. Next you need to assign the render event of the root console to a function. Visual Studio will probably create the function for you after you type “+=”.

rootConsole.Render += rootConsole_Render;
static void rootConsole_Render(object sender, UpdateEventArgs e)
{
    throw new NotImplementedException();
}

Replace the exception with the following code.

rootConsole.Clear();
rootConsole.Print(1, 1, "Hello World!", RLColor.White);
rootConsole.Draw();

Finally tell the Root Console to run on the last line of your main function.

rootConsole.Run();

Once this is executed, it will enter into a loop triggering the Render event until the window closes. (Or if we stop it ourselves, more on that later.)

Putting it all together
using RLNET;
using System;

namespace RLNET_Tutorial
{
    public class Program
    {
        public static RLRootConsole rootConsole;

        public static void Main()
        {
            rootConsole = new RLRootConsole("ascii_8x8.png", 60, 40, 8, 8);
            rootConsole.Render += rootConsole_Render;
            rootConsole.Run();
        }

        static void rootConsole_Render(object sender, UpdateEventArgs e)
        {
            rootConsole.Clear();
            rootConsole.Print(1, 1, "Hello World!", RLColor.White);
            rootConsole.Draw();
        }
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s