There are multiple ways of including rot.js in your project.
You can get rot.js using either of these methods:
- clone this repository to gain full source code access;
npm install rot-js;
- download the prebuilt rot.js file (or the minified rot.min.js file) to include it in your project.
Rot.js is written in TypeScript, but its code is available in multiple formats. You can pick the one that best suits your development needs.
For practical reasons, individual modules should be bundled to make your application more compact. You are free to use any bundler that understands ES2015 modules. If you want tu support older browsers, you should also transpile your code -- there is an example using babel and rollup that shows how to do that. This is the recommended way of using rot.js.
If you do not fancy modern modules and/or transpilation, you can grab a pre-built bundle and include it in your page using traditional
<script>tag. This bundle puts rot.js into a global
ROTnamespace and uses ES5 (supported even by older browsers). See an example of this approach.
Finally, the pre-built budle also comes with a minified version that works the same, but its size has been reduced. The usage is the same as in the previous example.
Display class needs to use the
"term" layout backend:
let display = width:40 height:9 layout:"term";display;display; // foreground colordisplay; // and background color
The pre-bundled rot.js package can be loaded as a CommonJS module. There is an example that shows basic usage.
RogueBasin page (with links to some rot.js-based games): http://www.roguebasin.roguelikedevelopment.org/index.php?title=Rot.js