Raylib plugin

raylib is a simple and easy-to-use library to enjoy videogames programming. You can find more information about raylib at the raylib website

How to learn coding with raylib

“raylib does not provide the typical API documentation or a big set of tutorials. The library is designed to be minimalistic and be learned just from a cheatsheet with all required functionality and a big collection of examples to see how to use that functionality. Best way to learn to code is reading code.” [raylib website, Aug. 2022]

Many of the original raylib examples, which are written in C, were converted to SmallBASIC and are available on Github. To make it easier for you, you will find all the converted examples in the list below. If you are new to raylib it is best to start with the first example.

The original cheatsheet for C can be found here. A simple SmallBASIC version is available at Github.

How to setup SmallBASIC to use the raylib plugin

The raylib plugin is included in the release version of SmallBASIC. SmallBASIC should find the plugin automatically. If you have problems loading the plugin, you can copy the library (libraylib.dll or libraylib.so) to the folder of your BASIC file. Additionally you need the file raylibc.bas. If it is not found automatically, please copy it to the folder of your BASIC file, too.

Since raylib uses its own window management, you cannot use it together with the SDL or FLTK version of SmallBASIC (sbasicg.exe or sbasicg). Please use instead the console version (sbasic.exe or sbasic):

  • Linux: sbasic MyRaylibProgram.bas.
  • AppImage: SmallBASIC-Console_12.24-x86_64.AppImage MyRaylibProgram.bas
  • Windows 11: sbasic.exe MyRaylibProgram.bas

If you are using the Linux Flatpak installation, you can start Raylib programs from the GUI (sbasicg).

You can specify the module directory:

  • Linux: sbasic -m PATH_TO_DLL myprogram.bas
  • Windows 11: sbasic.exe -m PATH_TO_DLL myprogram.bas

PATH_TO_DLL can be an absolute path like C:\myfolder or a relative path like ./mydlls. The relative path is relative to the location of you program.

Examples

Core examples

Shapes

Textures

Text

Audio

Models

Shaders

Physics

Miscellaneous

Structures and Variables

Camera2D

camera2D.target.x = 0
camera2D.target.y = 0
camera2D.offset.x = 0
camera2D.offset.y = 0
camera2D.rotation = 0
camera2D.zoom = 1

Camera3D

camera.position = [4, 2, 4]
camera.target = [0, 0, 0]
camera.up = [0, 1, 0]
camera.fovy = 60
camera.projection = c.CAMERA_PERSPECTIVE

Position

position = [0, 0, 0]

Rectangle

rectangle.x = 0
rectangle.y = 0
rectangle.width = 100
rectangle.height = 100
rectangle = {x: 0, y: 0, width: 100, height: 100}
rectangle = [x, y, width, height]
rectangle = [0, 0, 100, 100]

Vector2

vector2.x = 0
vector2.y = 0
vector2 = {x: 0, y: 0}
vector2 = [x, y]
vector2 = [0, 0]

Vector3

vector3.x = 0
vector3.y = 0
vector3.z = 0
vector3 = {x: 0, y: 0, z: 0}
vector3 = [x, y, z]
vector3 = [0, 0, 0]