ChaiScript bindings for raylib, a simple and easy-to-use library to enjoy videogames programming (www.raylib.com)
The following is an example of what raylib looks like through ChaiScript:
var screenWidth = 800
var screenHeight = 450
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
SetTargetFPS(60)
while (!WindowShouldClose()) {
BeginDrawing();
ClearBackground(RAYWHITE)
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
EndDrawing()
}
CloseWindow() // Close window and OpenGL context
Check for more examples organized by raylib modules.
There are a number of ways to use raylib-chaiscript. The following covers its API binding, and a launcher tool...
There is a command-line interface tool to quickly launch .chai files with raylib, named raylib-chaiscript. This allows running .chai scripts directly from the command line, or just with drag & drop of .chai files into raylib-chaiscript.exe:
./raylib-chaiscript core_basic_window.chai
It can be compiled for other platforms, just need to include ChaiScript and link raylib. For more details, just check comments on raylib-chaiscript.cpp.
To integrate raylib-chaiscript directly into an existing project, the single header-only file, raylib.hpp, is used. To add the raylib bindings to your project you will need to...
-
Include the file in your project:
#include "chaiscript/extras/raylib.hpp"
-
Add the module to your ChaiScript instance:
auto raylib = chaiscript::extras::raylib::bootstrap(); chai.add(raylib);
-
Evaluate a file with some raylib code:
chai.eval_file("core_basic_window.chai");
raylib-chaiscript is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.
Copyright (c) 2018 Rob Loach (@RobLoach)