Skip to content

lostfictions/rot.ts

 
 

Repository files navigation

rot.js for Node.js

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.

ROT.Display

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.

Istanbul coverage

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

Coverage exceptions

  • src/js/object.js provides Object.create for environments that do not have their own Object.create. Node.js provides this method, so the code provided by rot.js will never execute.

  • src/js/raf.js provides cancelAnimationFrame and requestAnimationFrame for environments that provide a window object, but do not provide their own animation frame functions. Node.js does not provide a window object, so the code provided by rot.js will never execute.

  • src/path/astar.js defines a method ROT.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. :-)

Packages

No packages published

Languages

  • JavaScript 57.5%
  • TypeScript 28.6%
  • HTML 11.3%
  • CSS 1.8%
  • Makefile 0.5%
  • CoffeeScript 0.3%