raylib-libreria-open-source-para-hacer-videojuegos

Raylib, Open Source library for making video games

  • 3 min

Raylib is an Open Source library for making video games, designed to be simple and easy to use, available on a wide variety of platforms and languages.

Raylib aims to move away from more complex and heavy video game solutions and engines, focusing on the most basic and fundamental aspects of video game development.

Thus, it eliminates the need for additional dependencies or adding huge frameworks or game engines to our project. It simply works, without major complications, and with an old-school flavor that is appreciated.

Among the fundamental features of the library we find, logically, the creation of 2D and 3D graphics. Its syntax is inspired by Borland BGI graphics and the XNA framework. It supports graphics accelerated by OpenGL (1.1, 2.1, 3.3, 4.3 or ES 2.0).

raylib-2d-example

In addition to the graphical aspect, raylib incorporates functionalities for simple physics simulation, such as collisions between objects. The set of core functions is completed with tools for managing user input, such as keyboard, mouse, or gamepad.

As mentioned earlier, one of the most interesting points is its compatibility with multiple architectures and OSes. These include Windows, Linux, macOS, Raspberry Pi, Android, and Web (HTML5). In fact, in theory, it should be compatible with any platform that can run C code and has OpenGL graphics.

Raylib is entirely developed in C (C99). However, there are bindings that allow us to use raylib from +60 programming languages. These include C#, Java, Rust, Dart, Go, Python, among others.

As we said, one of raylib’s strong points is its ease of use, compared to other much heavier solutions. For example, this is what a simple “hello world” developed with raylib would look like.

#include "raylib.h"

int main(void)
{
    InitWindow(800, 450, "raylib - basic window");

    while (!WindowShouldClose())
    {
        BeginDrawing();
        ClearBackground(RAYWHITE);
        DrawText("Congratulations, you have created a window!", 190, 200, 20, LIGHTGRAY);       
        EndDrawing();
    }

    CloseWindow();

    return 0;
}
Copied!

As we can see, there was no need to add a long list of dependencies or use a complex graphics engine. We only need to add the dependency to raylib and the necessary “skeleton” code to run it in our application is really simple.

The project has an extensive library of examples that document the main functions of the library. These can be run directly from the web, thanks to raylib’s compatibility with HTML5. They are available at https://www.raylib.com/examples.html.

raylib-3d-example

In its ten years of development, raylib has received numerous recognitions, including prestigious awards from well-known companies such as Google and Epic Games.

Raylib is complemented by a wide collection of very interesting libraries from the same author, such as raymath for mathematics, raudio for sound playback, or raygui for creating UIs, among others.

The project is excellently documented, with notable examples as mentioned earlier, as well as the “Cheatsheet” or “summary sheet” available at this link.