Sharpallegro Tutorial 1: Your first application


Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /homepages/30/d572126800/htdocs/web/elvenprogrammer.org/wordpress/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /homepages/30/d572126800/htdocs/web/elvenprogrammer.org/wordpress/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

Warning: WP_Syntax::substituteToken(): Argument #1 ($match) must be passed by reference, value given in /homepages/30/d572126800/htdocs/web/elvenprogrammer.org/wordpress/wp-content/plugins/wp-syntax/wp-syntax.php on line 383

This tutorial explain how to create your very first “Hello world” application using sharpallegro.

[ad]

Create a new empty project

Add a project reference to the sharpallegro library

Add a new class. Game.cs in our example.

Let’s start by adding a using directive to sharpallegro.

using allegro;

We need our class to inherit from the Allegro class to let it be able to use the allegro API.

using System;
using System.Collections.Generic;
using System.Text;
 
using allegro;
 
namespace Tutorial1
{
  class Game : Allegro
  {
  }
}

Have you already tried to compile? If so you already know we need to add a Main. Let’s do it.

using System;
using System.Collections.Generic;
using System.Text;
 
using allegro;
 
namespace Tutorial1
{
  class Game : Allegro
  {
    public static void Main()
    {
      allegro_init();
      allegro_message("Hello world!");
    }
  }
}

Launch the application and voila

Note: If you get an error while running the application you probably forgot to put alleg42.dll in your system directory or in the same folder as the tutorial executable.

Leave a Reply

Your email address will not be published.