Troll2D

Troll2d_logo.png

Troll is a free and open source software library for video game development, with functions for basic 2D graphics, image manipulation, text output, audio output, midi music, input and timers. Troll is written in C++ and is full Object-oriented, and easy to use. Uses Allegro or SDL as a back-end for low level manipulation of video, audio, and input. But it is possible to create a custom back-end.

Architecture

The main idea of Troll is to provide a common framework to work internally with any implementation without changing the code. For example, it can be used to write a game for windows using SDL, and than in the future use the same source for a Linux version using Allegro.

Trol_Layers.png

Sample Code

Game entry point, and main loop

int main()
{
        using namespace Troll;
    if(!System::Init()) // Initialize system
        return 1;

    if(!System::SetupScreen()) // Create screen
        return 1;

    Surface & screen = Screen::GetSurface(); // Get surface screen
    Graphics g(screen); // Create a Graphics object
    
    while(!KeyInput::IsKeyDown(Key::ESCAPE)) // key-esc was not pressed
    {
        g.DrawRect(Rect(10,10,200,200),Color(255,0,0)); // Draw a Rect
        Screen::Flip(); // Draw to screen (page flip, or blit)
    }
    return 0;
}

This code is a main loop of game, and draws a red rectangle until the ESC key is pressed

History

Troll was designed to abstract and help users to write games quickly. The main idea is to encapsulate common tasks involved in writing a game, and make it easy to write a game in a few lines of code. Troll supports Unix (Linux, FreeBSD, Irix, Solaris, Darwin), Windows, BeOS, QNX, Mac OS X, DOS, Symbian, Windows Mobile, and any platform that supports SDL or Allegro.

See also

  • Allegro library
  • SDL (Simple DirectMedia Layer)
  • DirectX
  • OpenGL
  • ClanLib
  • OpenML
  • XNA