S.A.L.D.

Studio A Ludum Dare JS Game Engine


Home | Reference | Examples | About Us


Project maintained by sald-devs Hosted on GitHub Pages — Theme by mattgraham

Welcome to SALD!

SALD is a lightweight custom built javascript game engine that enables users to develop games quickly and easily. This engine is written in JavaScript using the Node.js run time environment. The engine is divided distinctly into various modules which can be imported by the user. The user can then implement game mechanics and other aspects of the game using functions provided through these modules.

Installation

Fork this repo into desired location then from command line run

npm link

Having problems? Check Common Problems!

Usage

sald [command] args
          commands
            new/create [dir] - create a new sald project
            build - build sald project in cwd based on build.js
        

You will want to use sald create <myProjName> to create a starter project. It is not recommended to do this in the sald directory.

Edit and place files in the src folder created by sald. Then run:

sald build

A build.html file will be created in the directory that will contain the game!

Having problems? Check Common Problems!

Build Settings

The build.js file must be in the current working directory when calling sald build. This file should export an object which specifies the output location, entry point, and the method for handling custom file types. By default, Sald handles transformations for common types, like .js, .json, .png, .jpg, .wav, .ogg. You may override these with your own handlers if you wish. All other filetypes will need a handler implemented in this build.js.

Sald can also handle colonical transforms, specified like gradient:#000-#fff, for which you must specify a function which generates a JS block that exports the expected return value.

Each transform can also take the object form {canonicalFunc: aFunc, tranformFunc: bFunc}, where bFunc is what you used before, and aFunc is used to determine the canonical name of the parameter. This is used to ensure there is no duplication of resolved requires in the final output html file. If the transform is not in this object form, then a default canonical function is assumed (direct string comparison for colonicals, and normalized path comparison for file extension types).

Example build.js


function gradientCanon(param) {
  // some conversion here
  // ex: 'black-white' will be converted to '#000-#fff'
  return convertedString;
}

function gradientTransform(param) {
  // some external imagemagick call
  return 'var img = new Image(); img.src = ' + base64Data + '; module.exports = img;';
}

function unownCanon(filepath, rootpath) {
  // rootpath is the name of the folder where the require is called. Useful for relative require parsing, using _path.join_
  canonicalName = someTransformation();
  return canonicalName;
}

function unownLoader(filepath) {
  // filepath passed is the resule of unownCanon
  var someJsTxt = something //your loader
  return 'module.exports = ' + someJsTxt;
}

// Export build options
module.exports = {
  // Entry point for build
  entry :  {
    js : 'src/main.js',       //the script to be called
    html : 'src/main.html'    //will be used as template for final output
  },
  // Output options
  output : {
    html : 'build.html'  //location to output final built project
  },
  // Options for each file type
  transforms : {
    'gradient:': {
      canonicalFunc: gradientCanon,
      transformFunc: gradientTransform
    },
    '.unown': { // If a custom canonicalization is needed
      canonicalFunc: unownCanon,
      transformFunc: unownLoader
    },
    '.unown': unownLoader // If no custom canonicalization is needed for this type
};
        

This build.js file now knows what to do with a require('../pokedex/pokemon87.unown'); or require('gradient:black-white').

Having problems? Check Common Problems!

Libraries

Common Problems

Installation

Usage