• Stars
    star
    229
  • Rank 170,617 (Top 4 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 5 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Node.js bindings for Raylib

node-raylib Logo

node-raylib npm version Tests

Node.js bindings for raylib, a simple and easy-to-use library to enjoy videogames programming (www.raylib.com).

Examples

Name Description Author
Offical Examples Ports of raylib's examples to node-raylib @RobLoach, @twunky, @konsumer
Flappy A Flappy Bird clone @arthurmassanes
Retro RPG Template Small prototype to build a retro-inspired RPG game @konsumer
Chip8 A CHIP-8 emulator whose native client using node-raylib @taniarascia

Dependencies

Usage

  1. Create a new Node.js project:

    mkdir myexample
    cd myexample
  2. Create a package.json file with:

    {
      "dependencies": {
        "raylib": "*"
      },
      "scripts": {
          "start": "node index.js"
      }
    }
  3. Create a index.js 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 node-raylib window!", 120, 200, 20, r.LIGHTGRAY)
        r.EndDrawing()
    }
    r.CloseWindow()
  4. Have npm install the dependencies for you:

    npm install
  5. Run index.js through Node.js:

    npm start

    Screenshot

Check for more examples organized by raylib modules.

Installation

Raylib is implemented as bindings with node-addon-api. Bindings are prebuilt for many platforms in Releases. If your platform is not supported by a prebuilt binary, you will need CMake to build the native addon. Windows users building manually will also require MSVC Build Tools 2019, or Visual Studio 2019 with build tools for C/C++.

In general, to install node-raylib locally, use npm:

npm install raylib

DRM

On some ARM devices like Raspberry PI, raylib can be used in a DRM mode instead of rendering to an x11 window. This version requires a seperate native addon, and on installation on ARM devices node-raylib will include both. To use the DRM mode, import raylib/drm instead.

import * as rl from 'raylib/drm/index.js'
const rl = require('raylib/drm')

CLI

The project comes with a node-raylib command-line tool to run node-raylib files directly:

# Unix
./bin/node-raylib core_basic_window.js

# Windows
node bin/node-raylib core_basic_window.js

The CLI can be installed globally through npm or npx for no-install:

npm install raylib --global
node-raylib --version
npx -y raylib --version

Development

node-addon-api is used to construct the bindings. Raylib provides a header parser that generates a JSON file containing information on the API. The code binding raylib to NodeJS is automatically generated based on this file. For information on how bindings are written for raylib read the documentation. Code generators for the C++ bindings, TypeScript definitions, and JavaScript wrapper functions are found in the tools/generate_templates folder.

Testing

Run the following to run tests...

git clone https://github.com/RobLoach/node-raylib.git
cd node-raylib
npm i
npm t

TypeScript Definitions

Typescript definitions are provided by a generator based on raylib's header parser. See node-raylib-definitions.js for information on how to generate them.

Package

To build the packaged releases, use the following command:

npm run pkg

License

node-raylib 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) 2022 Rob Loach (@RobLoach)

More Repositories

1

raylib-cpp

C++ Object Oriented Wrapper for raylib
C++
358
star
2

component-installer

Install Web Components through Composer
JavaScript
280
star
3

docker-composer

🙆‍♀️ Docker container to install and run Composer.
Makefile
104
star
4

raylib-lua-sol

A simple and easy-to-use Lua library to enjoy videogames programming
C++
77
star
5

jquery-once

💲 Act on jQuery elements only once.
JavaScript
61
star
6

raylib-nuklear

Nuklear immediate mode GUI for raylib
C
56
star
7

Dockie

🐳 Collection of Modern Development Environments for Docker
Shell
50
star
8

base16-geany

🔮 Base16 Scheme for Geany
Makefile
40
star
9

lutris-kodi-addon

Lutris Kodi Addon
Python
38
star
10

libretro-dolphin-launcher

Launch Dolphin from RetroArch/libretro
C
37
star
11

raylib-aseprite

Load Aseprite files for animated sprites in raylib.
C
37
star
12

docker-compose-drupal

DEPRECATED: Use Docker4Drupal
31
star
13

raylib-duktape

C++
30
star
14

docker-pa11y

pa11y Docker Container
Dockerfile
27
star
15

libretro-dats

Build some of the libretro-database DATs
JavaScript
24
star
16

raylib-physfs

Integrate PhysFS with raylib to load images, audio, and fonts, from .zip files.
C
24
star
17

generator-docpad

✏️ Yeoman generator for DocPad
JavaScript
21
star
18

raylib-tmx

Load Tiled .tmx files for tile maps in raylib, using the TMX C Loader.
C
20
star
19

raylib-libretro

👾 libretro frontend using raylib.
C
19
star
20

drush-docker

🐳 Docker Container to run Drush
Dockerfile
19
star
21

libretro-thumbnails-check

Checks consistency of libretro-thumbnails
JavaScript
19
star
22

raylib-app

Application wrapper for raylib
C
15
star
23

retroarch-theme-materialdesign

Material Design theme for RetroArch
PHP
14
star
24

Bunnymark-TIC80

Bunnymark ported to a few languages in TIC-80 for performance testing.
Lua
13
star
25

docpad-plugin-grunt

🐗 Run Grunt.js tasks when building with DocPad
CoffeeScript
13
star
26

Awesome-ChaiScript

A curated list of ChaiScript Modules and Utilities.
12
star
27

docker-lamp

DEPRECATED: See Forge instead
PHP
12
star
28

ecwolf

Git mirror of ECWolf
C++
12
star
29

libretro-database-scummvm

ScummVM.dat file to run ScummVM games in RetroArch
JavaScript
12
star
30

sdl2_gfx

SDL2_gfx Mirror, likely out of date
HTML
11
star
31

docker-google-appengine

Google App Engine Docker container
Shell
10
star
32

xor-crypt

🔣 Simple JavaScript XOR string encryption library
HTML
10
star
33

composer.deb

Build a Debian package to install and use Composer.
Makefile
10
star
34

ChaiLove-Launcher

🚀 Launch applications through ChaiLove
9
star
35

raylib-wasm

WIP
C
9
star
36

ChaiLove-FloppyBird

🐦 Flappy Bird in ChaiLove
9
star
37

raylib_functions_parser

Fork of raysan5's raylib.h parser to output JSON
C
9
star
38

docpad-plugin-webpack

✏️ Bundle CommonJs/AMD Modules using webpack
CoffeeScript
8
star
39

nuklear_sdl_12

SDL 1.2 support for Nuklear
C
8
star
40

raylib-tileson

Use Tiled maps in raylib, through Tileson.
C++
7
star
41

DangerousDave-TIC80

Dangerous Dave in TIC-80
7
star
42

raylib-api

Exports of the raylib API from raylib_parser
Lua
7
star
43

awesome-sdl

Curated list of awesome libraries and bindings for SDL.
7
star
44

net.lutris.Lutris.old

Lutris for Flatpak
6
star
45

raylib-chaiscript

ChaiScript bindings for raylib, a simple and easy-to-use library to learn videogames programming.
C++
6
star
46

wren-bind

C
5
star
47

tic80-js

Bundle your TIC-80 JavaScript ES6 Games
JavaScript
5
star
48

datfile

ClrMamePro DAT file parser for Node.js
JavaScript
5
star
49

love-lutris

Lutris game launcher for Love2D or RetroArch/libretro
Lua
5
star
50

httpserver

PHP 5.4 HTTP Server wrapper.
PHP
4
star
51

wren-assert

Minimalistic assertion library for unit testing in Wren.
Makefile
4
star
52

asdf-emsdk

Emscripten SDK plugin for asdf version manager
Shell
4
star
53

ubuntu-mate

GRUB2 Theme for Ubuntu MATE
Shell
4
star
54

raylib-meson

raylib meson build system.
Meson
4
star
55

scriptpacker

Package multiple Wren, Squirrel or ChaiScript files into one, through JavaScript.
JavaScript
4
star
56

pntr

Image manipulation library for C.
C
4
star
57

docker-clean

🐳 Kill and delete all Docker containers and images
Shell
4
star
58

docker-fig-php

A port of the Fig Quick Start example to PHP and MySQL
PHP
4
star
59

libretrojs

C++
3
star
60

wren-path

Work with file and directory paths in Wren.
3
star
61

SDL_physfs

PhysFS virtual file system support for SDL.
C
3
star
62

Fission

A C++-ish wrapper for nuklear
C++
3
star
63

awesome-dats

A curated list of awesome DAT files.
JavaScript
3
star
64

raylib-assert

Minimalistic assertion library for raylib.
C
3
star
65

libretro-database-dos

DOS.dat for libretro-database
JavaScript
3
star
66

slides

Presentation slides for various conferences
HTML
3
star
67

ChaiScript_Extras_Box2D

ChaiScript Box2D Bindings
C++
3
star
68

language-drupal

Drupal syntax highlighting and snippets for Atom.io
CoffeeScript
3
star
69

bowersatis

Satis repository to index Bower packages.
PHP
3
star
70

libretro-rimage

Use pntr instead
C
3
star
71

Sokoban

Sokoban for Dinothawr
3
star
72

component-installer-example

An example of using Component Installer.
HTML
3
star
73

raylib-umka

Umka language bindings for raylib.
C
3
star
74

dotfiles

📂 My Dotfiles
Shell
3
star
75

sdl2js

SDL2.js - Experimental Node.js bindings to SDL2.
JavaScript
2
star
76

rimage

Use raylib's Image module by itself.
C
2
star
77

CMakePacks

CMake definition file for Duktape, raylib, and Umka.
C
2
star
78

raylib-assetsys

Use the file system abstraction library, assetsys.h, to load raylib assets from .zip files.
C
2
star
79

raylib-squirrel

C++
2
star
80

assetic-bundle

Sculpin bundle to add support for Assetic?
PHP
2
star
81

ChaiScript.js

JavaScript port of ChaiScript
HTML
2
star
82

metalsmith-jstransformer-layouts

Deprecated with Metalsmith JSTransformer
JavaScript
2
star
83

docker-drupal8

DEPRECATED: See /robloach/forge instead.
Shell
2
star
84

raylib-imagedraw

Extra Image manipulation methods for raylib.
C
2
star
85

Threes-TIC80

Threes in TIC-80
JavaScript
2
star
86

libretro-database-tic80

TIC-80 database for libretro
JavaScript
2
star
87

reveal-giphy

Rapid Giphy Reveal.js presentations
JavaScript
2
star
88

require-one

🎣 Require the first found module from an array.
JavaScript
2
star
89

raygui-container

Adds state to raygui, allowing for gamepad/keyboard-only support.
C
2
star
90

node-sdl2-pong

Pong, using Node.js and SDL2
JavaScript
1
star
91

node-sdl2-gfx

SDL2_gfx bindings for Node.js
JavaScript
1
star
92

libretro-fbg

C
1
star
93

pntr_app

Application wrapper for pntr.
C
1
star
94

YoxViewOld

A GIT branch from YoxView.
JavaScript
1
star
95

node-physfs

PhysicsFS (physfs) bindings for Node.js
JavaScript
1
star
96

docker-docpad

DEPRECATED: See docpad/dockerfile instead
Shell
1
star
97

ChaiLove-JSTest

🎮 Simple ChaiLove Joystick test application
1
star
98

jquery.ui.widget

jQuery UI Widget
JavaScript
1
star
99

wasm4-as

Drop-in replacement to WASM-4's wasm4.ts to make using AssemblyScript with WASM-4 easy
TypeScript
1
star
100

metalsmith-json-feed

Experimental use of a JSON Feed in Metalsmith
JavaScript
1
star