There are several map generator tools in rot.js
; they all share the same usage pattern. You first need to instantialize the proper ROT.Map.*
object and pass size (plus any additional relevant options) to its constructor; you can then call the main create
method (repeatedly, if you want).
This toolkit does not force usage of any particular memory structure to store the map data. Instead, the map creation process is callback-based:
you supply a callback function as an argument to the create
method;
the map creator will call your function repeatedly and pass it the generated map information. Your callback should accept these arguments:
x
– horizontal coordinate of a map's celly
– vertical coordinate of a map's cellvalue
– integer value corresponding to the type of generated cell (different values might be supplied by different map generators)These examples use the simplest map generator, Arena
: a fully dug room.
We can use ROT.Display
to show the generated map (although it would make more sense to store the generated data as well). For debugging purposes,
ROT.Display
provides a built-in convenience method DEBUG
, which works as a universal debugging callback.
Read more about various types of generators: Maze, Cellular and Dungeon.