node-raylib
Node.js bindings for raylib, a simple and easy-to-use library to enjoy videogames programming (www.raylib.com).
Dependencies
Usage
-
Add robloach/node-raylib
to your package.json dependencies:
npm init
npm install raylib --save
-
Create a JavaScript file, like core_basic_window.js
:
const r = require('raylib')
const screenWidth = 800
const screenHeight = 450
r.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
r.SetTargetFPS(60)
while (!r.WindowShouldClose()) {
r.BeginDrawing();
r.ClearBackground(r.RAYWHITE)
r.DrawText("Congrats! You created your first window!", 190, 200, 20, r.LIGHTGRAY)
r.EndDrawing()
}
r.CloseWindow()
-
Run it through Node.js:
node core_basic_window.js
Check for more examples organized by raylib modules.
What's Missing?
CLI
The project also comes with a node-raylib
command-line tool to run node-raylib
files directly:
./node-raylib core_basic_window.js
node-raylib.exe core_basic_window.js
The CLI can be installed with the packaged releases, or globally through npm
:
npm install raylib --global
node-raylib --version
Development
The following are a few notes and resources when developing node-raylib
...
Node.js Bindings
node-addon-api is used to construct the bindings. Feel free to read through src/addons.cc
for an understanding on how methods are defined. A lot is missing from the project, so feel free to get involved in the issue queue and submit pull requests. Run the following to run tests...
npm it
Package
To build the packaged releases, use the following command:
npm run pkg
License
raylib-nodejs 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)