Giter Site home page Giter Site logo

neverball-solid's Introduction

neverball-solid

neverball-solid parses Neverball SOL files.

Neverball is a rolling-ball game and SOL is the binary format used for its levels and models.

Install

$ npm install neverball-solid

Usage

var Solid = require('neverball-solid');

document.addEventListener('DOMContentLoaded', function () {
    var reader = new FileReader();

    reader.onload = function () {
        var sol = Solid(reader.result);
        var total = 0;

        for (var i = 0; i < sol.items.length; ++i) {
            if (sol.items[i].t === Solid.ITEM_COIN) {
                total += sol.items[i].n;
            }
        }

        console.log('Coins: $' + total);
    };

    var fileInput = document.querySelector('input[type="file"]');

    fileInput.addEventListener('change', function () {
        if (!fileInput.files.length) {
            return;
        }
        reader.readAsArrayBuffer(fileInput.files[0]);
    });
});

API

var Solid = require('neverball-solid');

var sol = Solid(buffer)

Load the SOL data from buffer. buffer can be an ArrayBuffer obtained from an XMLHttpRequest or a FileReader; it can also be a Node.js Buffer. Throw if 1) the buffer does not contain SOL data or 2) the loader doesn't support the reported SOL version.

Constants

All of the SOL constants for material flags, item types, etc., are available as properties of the exported object.

Notation

neverball-solid largely adopts the same kind of terse notation for the various SOL attributes that's used in share/solid_base.h. The only deviation from that is the addition of aliases, e.g., sol.items is an alias for sol.hv.

License

GPL-3.0+

neverball-solid's People

Contributors

parasti avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.