Ondrej Zara's ROguelike Toolkit for Node.js
ROguelike Toolkit in JavaScript. For more info, see http://ondras.github.com/rot.js.
To install rot.js
, pick one:
- clone this repository to gain full source code access;
- download just the minified rot.min.js file to include it in your project;
RogueBasin page (with links to some rot.js-based games): http://www.roguebasin.roguelikedevelopment.org/index.php?title=Rot.js
There is an incredible interactive manual to learn rot.js. The notes below are specific to the Node.js version.
The Node.js version does not have a <canvas>
element, and so the standard
layout
algorithms (rect
and hex
) do not work. The Node.js version does,
however, have its own layout type: term
var display = new ROT.Display({width:40, height:9, layout:"term"});
display.draw(5, 4, "@");
display.draw(15, 4, "%", "#0f0"); /* foreground color */
display.draw(25, 4, "#", "#f00", "#009"); /* and background color */
RGB colors are supported for xterm
compatible terminals.
A set of unit tests offering nearly universal coverage is available.
git clone https://github.com/ondras/rot.js
cd rot.js
make node
npm install
cake coverage
-
src/js/object.js
providesObject.create
for environments that do not have their ownObject.create
. Node.js provides this method, so the code provided by rot.js will never execute. -
src/js/raf.js
providescancelAnimationFrame
andrequestAnimationFrame
for environments that provide awindow
object, but do not provide their own animation frame functions. Node.js does not provide awindow
object, so the code provided by rot.js will never execute. -
src/path/astar.js
defines a methodROT.Path.AStar.prototype._distance
that contains a switch statement. There are some unreachable break statements here to improve code aesthetics (case/break balance). -
Some of the tests rely on the random generation process to cover the cases of the generator. On bad runs, a poor random seed will leave coverage gaps. In this case, re-run the tests until you are happy. :-)