Studio A Ludum Dare JS Game Engine
Home | Reference | Examples | About Us
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.
Fork this repo into desired location then from command line run
npm link
Having problems? Check Common Problems!
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!
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 colon
ical 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 require
s 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 colon
icals, and normalized path comparison for file extension types).
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!
Sudo may be required on Mac or Linux, or the command prompt may need to be run as administrator on Windows.
If you encounter path issues in windows you probably have to convert line endings from dos to unix format on ..\sald\bin\sald.js We reccomend using a tool like dos2unix
The current version of node.js for windows has a bug. If you receive an ENOENT error, check here
In windows you might need to give sald build the project you are trying to build. For example if you are currently in the root directory of your sald project you need to run:
sald build ./
OR sald build <path to sald project>