🔊 Raylib is a library used for game development, however, there are other areas of application. Despite having native support for C/C++, it is possible to use it in other programming languages such as: Lua, Golang, C#, Python, PHP , Java and among others.
Some features of Raylib are:
Releases
on the right side of the screenF6
and then press [OK] to compile# ubuntu
sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
# fedora
sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel libatomic
# Arch Linux
sudo pacman -S alsa-lib mesa libx11 libxrandr libxi libxcursor libxinerama
For more information click here.
git clone https://github.com/raysan5/raylib
cd raylib
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make up
sudo make install
sudo cp /usr/local/lib/libraylib.so.420 /usr/lib/
Now you can remove the cloned directory:
cd ../.. && rm -rf raylib
main.cpp
#include "raylib.h"
int main(){
InitWindow(800, 450, "raylib [core] example - basic window");
while (!WindowShouldClose()){
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
EndDrawing();
}
CloseWindow();
return 0;
}
g++ main.cpp -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
main.cpp
namespace ray {
#include <raylib.h>
}
int main(){
ray::InitWindow(1280, 720, "Getting started with Raylib");
ray::Texture sprite, bg;
sprite = ray::LoadTexture("./sprite.png");
bg = ray::LoadTexture("./bg.png");
float posx = -sprite.width;
while( !ray::WindowShouldClose() ){
posx += 0.9f;
if( posx > 1280 ){
posx = -sprite.width;
}
ray::BeginDrawing();
ray::ClearBackground(ray::WHITE);
ray::DrawText("First steps with Raylib", 50, 100, 50, ray::BLACK);
ray::DrawTexture(bg, 0, 0, ray::WHITE);
ray::DrawTexture(sprite, posx, 630 - sprite.height, ray::WHITE);
ray::EndDrawing();
}
ray::CloseWindow();
return 0;
}
sprite.png
bg.png
Note: The video is in Portuguese, but it is possible to follow the steps described in this article and the development from scratch of the code used as an example.