New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

raylib

Package Overview
Dependencies
Maintainers
3
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

raylib

Node.js bindings for raylib.

  • 0.9.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
decreased by-19.44%
Maintainers
3
Weekly downloads
 
Created
Source

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).

Sample Applications

Dependencies

Usage

  1. Create a new Node.js project:

    mkdir myexample
    cd myexample
    npm init
    
  2. Use the runtime by adding this to the scripts section of your package.json.

{
    "scripts": {
        "start": "npx -y raylib"
    }
}
  1. 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 window!", 190, 200, 20, r.LIGHTGRAY)
        r.EndDrawing()
    }
    r.CloseWindow()        // Close window and OpenGL context
    
  2. Run index.js through Node.js:

    npm start
    

Check for more examples organized by raylib modules.

Installation

Raylib is implemented as bindings with the 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++.

CLI

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

# Unix
./node-raylib core_basic_window.js

# Windows
node-raylib.exe core_basic_window.js

The CLI can be installed with the packaged releases, or globally through npm or npx for no-install:

npm install raylib --global
node-raylib --version

npx -y raylib --version

Development

The following are a few notes and resources when developing node-raylib...

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 docs here. Code generators for the C++ bindings, TS Definitions, and JS wrapper functions are located here.

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 here 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)

Keywords

FAQs

Package last updated on 11 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc