A node.js wrapper for the C++ game engine Diamond.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Build Status

jdiamond is a JavaScript game engine for desktop games. It is a node.js interface for Diamond, a 2D C++ game engine. It allows you to develop high-performance PC games that are rendered on native graphics libraries such as OpenGL. And unlike some desktop game engines that feature "JavaScript" scripting, it runs in a real node.js environment, allowing you to take full advantage of JavaScript features and the massive variety of node.js libraries.


To make a game, just require jdiamond, initialize the engine, and construct your gameobjects. Create an update callback to handle game logic, and then launch your game.

const Diamond = require('jdiamond');

if (Diamond.init()) {
    const shipSprite = Diamond.renderer.loadTexture("laserShip.png");

    // use a JavaScript object to easily build an entity-component model.
    // this entity has the components transform and renderer.
    const laserShip = new function() {
        this.transform = new Diamond.Transform2({x: 600, y: 100});
        this.renderer = new Diamond.RenderComponent2D(this.transform, shipSprite);

    // this function will be called every frame.
    // here, we are making our ship fly around in a circle.
    const update = function(delta) {
                {x: delta, y: 0},
                laserShip.transform.rotation * Diamond.Math.DEG2RAD
        laserShip.transform.rotation += delta;

// game over!


OSX or Windows is required, but Windows is not officially supported (in particular, some Windows binaries may be out of date). We might support Linux in the future.

If you don't already have node.js, install it from here. Then in your project folder, run:

$ npm install jdiamond

You also need to have SDL2, SDL2 image, SDL2 mixer, and SDL2 ttf installed. If you don't have them already, follow the instructions for your platform:


You can use our install script to automatically download and install the SDL frameworks:

$ sudo ./node_modules/jdiamond/install_deps

If you can't sudo, you can install SDL to your user directory instead:

$ ./node_modules/jdiamond/install_deps ~/Library/Frameworks


As far as we know, SDL does not have an executable installer, and we haven't made one yet. This means that, for now, you'll have to manually install all of the DLLs in jdiamond/src/CDiamond/extern/SDL2/lib/[your architecture]/. You can copy those DLLs to your node.js directory (ex. C:\Program Files\nodejs) and jdiamond should be able to find them. Or, you could install them to C:\Windows\System32, but we haven't been able to do this successfully (if you're Windows-savvy, please consider contributing to the project!).


jdiamond uses node-ffi to communicate with the C++ Diamond library. See node-ffi for license details.

Diamond uses Simple DirectMedia Layer (SDL), which is Copyright (c) 1997-2014 Sam Lantinga slouken@libsdl.org.

jdiamond is Copyright 2016 Ahnaf Siddiqui, and is licensed under the Apache License, Version 2.0 (see LICENSE file).

Artwork (such as laserShip.png and monomer.png) is Copyright 2016 Shah Akandh, all rights reserved.