### Build Process Commands Source: https://github.com/ondras/rot.js/blob/master/README.md Installs project dependencies and builds all project assets. ```bash npm install make all ``` -------------------------------- ### start Source: https://github.com/ondras/rot.js/blob/master/doc/classes/engine.default.html Starts the main loop of the engine. Once this method is called and returns, the loop is considered locked. ```APIDOC ## start ### Description Starts the main loop of the engine. Once this method is called and returns, the loop is considered locked. ### Method None (This is a method call on an instance) ### Endpoint None (This is a method call on an instance) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Returns * [default](engine.default.html) - The engine instance, allowing for chaining. ``` -------------------------------- ### Digger Dungeon Generation Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/map/dungeon.html Generates a dungeon using the Digger algorithm and retrieves room information. Includes a custom door drawing function. ```javascript ROT.RNG.setSeed(1234); var map = new ROT.Map.Digger(); var display = new ROT.Display({fontSize:8}); SHOW(display.getContainer()); map.create(display.DEBUG); var drawDoor = function(x, y) { display.draw(x, y, "", "", "red"); } var rooms = map.getRooms(); for (var i=0; i [%s, %s]", (i+1), room.getLeft(), room.getTop(), room.getRight(), room.getBottom() )); room.getDoors(drawDoor); } ``` -------------------------------- ### Passing Additional Arguments to Format Functions Source: https://github.com/ondras/rot.js/blob/master/manual/pages/format.html Demonstrates how to pass additional arguments to formatting functions using the _{,}_ notation. This example defines an 'adjective' method for an Animal prototype. ```javascript var Animal = function(name) { this._name = name; } Animal.prototype.adjective = function(x) { return x + " " + this._name; } ROT.Util.format.map.adjective = "adjective"; var cat = new Animal("cat"); var template = "You see a %{adjective,black}."; SHOW( ROT.Util.format(template, cat) ); ``` -------------------------------- ### Training and Generating Strings with ROT.StringGenerator Source: https://github.com/ondras/rot.js/blob/master/manual/pages/stringgenerator.html This example demonstrates how to train ROT.StringGenerator with a list of strings and then generate new strings based on that training. It fetches training data from a URL and displays generated strings. ```javascript var sg = new ROT.StringGenerator(); var r = new XMLHttpRequest(); r.open("get", "java.txt", true); r.send(); r.onreadystatechange = function() { if (r.readyState != 4) { return; } var lines = r.responseText.split("\n"); while (lines.length) { var line = lines.pop().trim(); if (!line) { continue; } sg.observe(line); } for (var i=0; i<20; i++) { SHOW(sg.generate()); } } ``` -------------------------------- ### getTop Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Room.html Gets the top-most coordinate of the room. ```APIDOC ## getTop ### Description Gets the top-most coordinate of the room. ### Method N/A (JavaScript method) ### Returns number - The top-most y-coordinate of the room. ``` -------------------------------- ### Corridor Constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Corridor.html Initializes a new Corridor instance with start and end coordinates. ```APIDOC ## constructor ### Description Initializes a new Corridor instance with start and end coordinates. ### Method `new Corridor(startX: number, startY: number, endX: number, endY: number)` ### Parameters #### Parameters - **startX** (number) - The starting X coordinate. - **startY** (number) - The starting Y coordinate. - **endX** (number) - The ending X coordinate. - **endY** (number) - The ending Y coordinate. ### Returns - [Corridor](map_features.Corridor.html) - A new Corridor instance. ``` -------------------------------- ### setOptions Source: https://github.com/ondras/rot.js/blob/master/doc/classes/lighting.default.html Adjusts the lighting options at runtime. This method allows for dynamic modification of lighting parameters after the initial setup. ```APIDOC ## setOptions ### Description Adjust options at runtime ### Method (Implicitly a method of the Lighting class) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **options** (Partial) - Description not available in source. ### Request Example ```json { "options": { "range": 5, "emissionThreshold": 0.2 } } ``` ### Response #### Success Response (200) (Implicitly returns the Lighting instance for chaining, as indicated by the return type '[default](lighting.default.html)') #### Response Example (No explicit example provided in source) ``` -------------------------------- ### Simple Scheduler Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/timing/scheduler.html Demonstrates the ROT.Scheduler.Simple API for round-robin scheduling of recurring actors. Use when a strict turn order is desired. ```javascript var scheduler = new ROT.Scheduler.Simple(); /* generate some actors */ for (var i=0;i<4;i++) { scheduler.add(i+1, true); /* true = recurring actor */ } /* simulate several turns */ var turns = []; for (var i=0;i<20;i++) { var current = scheduler.next(); turns.push(current); } SHOW("\nGenerated order of actors:"); SHOW(turns.join(" ") + " ..."); ``` -------------------------------- ### compute Method Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_path.default.html Computes the path from a starting point to the target coordinates. This is the main method for pathfinding. ```APIDOC ## compute ### Description Computes the path from a starting point to the target coordinates. ### Parameters * **fromX** (number) - The starting X coordinate. * **fromY** (number) - The starting Y coordinate. ### Returns * number[][] - An array of coordinates representing the computed path. ``` -------------------------------- ### ROT.Engine with Locking Mechanism Source: https://github.com/ondras/rot.js/blob/master/manual/pages/timing/engine.html Demonstrates the traditional ROT.Engine usage, including starting the engine, locking/unlocking for asynchronous operations, and managing actors. ```javascript var scheduler = new ROT.Scheduler.Simple(); var engine = new ROT.Engine(scheduler); var output = []; /* sample actor: pauses the execution when dead */ var actor1 = { lives: 3, act: function() { output.push("."); this.lives--; if (!this.lives) { scheduler.remove(actor1); engine.lock(); /* pause execution */ setTimeout(unlock, 500); /* wait for 500ms */ } } } scheduler.add(actor1, true); var unlock = function() { /* called asynchronously */ var actor2 = { act: function() { output.push("@"); } } output = []; scheduler.add(actor2, false); /* add second (non-repeating) actor */ engine.unlock(); /* continue execution */ SHOW(output.join("")); } engine.start(); SHOW(output.join("")); ``` -------------------------------- ### IceyMaze Generation Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/map/maze.html Generates mazes with configurable regularity using Icey's algorithm. Regularity (0 for most random) is set as the third argument. Requires ROT.Map.IceyMaze and ROT.Display. ```javascript var w = 39, h = 25; for (var i=0; i<4; i++) { var display = new ROT.Display({width:w, height:h, fontSize:6}); SHOW(display.getContainer()); var maze = new ROT.Map.IceyMaze(w, h, 4*i); maze.create(display.DEBUG); } ``` -------------------------------- ### DividedMaze Generation Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/map/maze.html Generates a maze using the Recursive Division method. Requires ROT.Map.DividedMaze and ROT.Display. ```javascript var w = 39, h = 25; var dm = new ROT.Map.DividedMaze(w, h); for (var i=0; i<4; i++) { var display = new ROT.Display({width:w, height:h, fontSize:6}); SHOW(display.getContainer()); dm.create(display.DEBUG); } ``` -------------------------------- ### Pathfinding with Hexagonal Topology Source: https://github.com/ondras/rot.js/blob/master/manual/pages/hex/about.html Utilize hexagonal topology for pathfinding algorithms by passing `topology:6` as an option. This example generates a map, sets up a passable callback, and computes a Dijkstra path. ```javascript var w = 150, h = 80; ROT.RNG.setSeed(12345); var display = new ROT.Display({width:w, height:h, fontSize:6, layout:"hex"}); SHOW(display.getContainer()); /* generate map and store its data */ var data = {}; var map = new ROT.Map.Cellular(w, h, { topology: 6, born: [4, 5, 6], survive: [3, 4, 5, 6] }); map.randomize(0.48); map.create(); /* two iterations */ map.create(function(x, y, value) { data[x+","+y] = value; display.DEBUG(x, y, value); }); /* input callback informs about map structure */ var passableCallback = function(x, y) { return (data[x+","+y] === 0); } /* prepare path to given coords */ var dijkstra = new ROT.Path.Dijkstra(120, 64, passableCallback, {topology:6}); /* compute from given coords */ dijkstra.compute(30, 16, function(x, y) { display.draw(x, y, "", "", "#800"); }); /* highlight */ display.draw(30, 16, "", "", "#3f3"); display.draw(120, 64, "", "", "#f33"); ``` -------------------------------- ### Eller's Perfect Maze Generation Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/map/maze.html Generates a perfect maze using Eller's algorithm, which guarantees a single path between any two cells and is memory-efficient. Requires ROT.Map.EllerMaze and ROT.Display. ```javascript var w = 39, h = 25; var em = new ROT.Map.EllerMaze(w, h); for (var i=0; i<4; i++) { var display = new ROT.Display({width:w, height:h, fontSize:6}); SHOW(display.getContainer()); em.create(display.DEBUG); } ``` -------------------------------- ### Action-Duration Scheduler Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/timing/scheduler.html Demonstrates ROT.Scheduler.Action for scheduling actions with variable durations. Requires calling setDuration() after next(). Use when actions have different time costs. Initial delay can be set with add(). ```javascript var scheduler = new ROT.Scheduler.Action(); /* generate some actors */ for (var i=0;i<4;i++) { scheduler.add(i+1, true, i); /* last argument - initial delay */ } /* simulate several turns */ var template = "Actor %s performing action for %s time units (current time: %s)"; for (var i=0;i<20;i++) { var current = scheduler.next(); var actionDuration = Math.ceil(ROT.RNG.getUniform() * 20); scheduler.setDuration(actionDuration); var padded = actionDuration.toString().padStart(2, "0"); SHOW(ROT.Util.format(template, current, padded, scheduler.getTime())) } ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/display_term.default.html Initializes a new instance of the default display backend. This constructor overrides the one from the base Backend class. ```APIDOC ## constructor ### Description Initializes a new instance of the default display backend. This constructor overrides the one from the base Backend class. ### Method constructor ### Returns [default](display_term.default.html) ### Source Defined in [display/term.ts:34](https://github.com/ondras/rot.js/blob/394b3e4/src/display/term.ts#L34) ``` -------------------------------- ### get Source: https://github.com/ondras/rot.js/blob/master/doc/classes/noise_simplex.default.html Generates Simplex noise for a given 2D coordinate. This method overrides the base get method from the noise module. ```APIDOC ## get ### Description Generates Simplex noise for a given 2D coordinate. This method overrides the base get method from the noise module. ### Method (Implicitly a method of the Simplex noise class) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (None) ### Parameters - **xin** (number) - The x-coordinate. - **yin** (number) - The y-coordinate. ### Returns number The generated Simplex noise value. ``` -------------------------------- ### Constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_path.default.html Initializes a new instance of the pathfinding class. It requires the target coordinates, a callback function to determine map passability, and optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the pathfinding class. ### Parameters * **toX** (number) - Target X coordinate. * **toY** (number) - Target Y coordinate. * **passableCallback** ([PassableCallback]) - Callback function to determine map passability. * **options** (Partial<[Options]>) - Optional configuration object. Defaults to an empty object. ### Returns * [default] - The newly created instance of the pathfinding class. ``` -------------------------------- ### getRight Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Room.html Gets the right-most coordinate of the room. ```APIDOC ## getRight ### Description Gets the right-most coordinate of the room. ### Method N/A (JavaScript method) ### Returns number - The right-most x-coordinate of the room. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/lighting.default.html Initializes a new instance of the Lighting Default class. It requires a reflectivity callback and accepts optional lighting options. ```APIDOC ## constructor ### Description Initializes a new instance of the Lighting Default class. It requires a reflectivity callback and accepts optional lighting options. ### Parameters #### Parameters - **reflectivityCallback**: ReflectivityCallback - The callback function to determine reflectivity. - **options**: Partial - Optional partial object for configuring lighting options. ``` -------------------------------- ### getLeft Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Room.html Gets the left-most coordinate of the room. ```APIDOC ## getLeft ### Description Gets the left-most coordinate of the room. ### Method N/A (JavaScript method) ### Returns number - The left-most x-coordinate of the room. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_dijkstra.default.html Initializes a new instance of the Dijkstra pathfinding algorithm. It requires the target coordinates, a callback function to determine passable cells, and optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the Dijkstra pathfinding algorithm. ### Method new default(toX: number, toY: number, passableCallback: PassableCallback, options: Partial): default ### Parameters #### Path Parameters * **toX** (number) - The target X coordinate. * **toY** (number) - The target Y coordinate. * **passableCallback** (PassableCallback) - A function that returns true if a cell is passable, false otherwise. * **options** (Partial) - Optional configuration options for the pathfinding algorithm. ### Returns * **default** - A new instance of the Dijkstra pathfinder. ``` -------------------------------- ### getTime Source: https://github.com/ondras/rot.js/blob/master/doc/classes/scheduler_scheduler.default.html Gets the current time of the scheduler. ```APIDOC ## getTime ### Description Gets the current time of the scheduler. See ROT.EventQueue#getTime. ### Method getTime() ### Parameters None ### Returns number ``` -------------------------------- ### Initialize TileGL Display Source: https://github.com/ondras/rot.js/blob/master/manual/pages/tiles.html Demonstrates how to create a ROT.js display instance using the TileGL layout. Requires a tile set image and defines tile mappings and dimensions. ```javascript SHOW(ROT.Display.TileGL.isSupported()); var tileSet = document.createElement("img"); tileSet.src = "tiles.png"; var options = { layout: "tile-gl", bg: "transparent", tileWidth: 64, tileHeight: 64, tileSet: tileSet, tileColorize: true, tileMap: { "@": [0, 0], "#": [0, 64], "a": [64, 0], "!": [64, 64] }, width: 10, height: 10 } var display = new ROT.Display(options); SHOW(display.getContainer()); ``` -------------------------------- ### getCorridors Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_uniform.default.html Gets all generated corridors. Inherited from ROT.Map. ```APIDOC ## getCorridors ### Description Gets all generated corridors. Inherited from ROT.Map. ### Method N/A (Inherited) ### Returns - **Corridor[]** - An array of Corridor objects. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/noise_noise.default.html Initializes a new instance of the default noise generator. ```APIDOC ## constructor ### Description Initializes a new instance of the default noise generator. ### Returns * [default](noise_noise.default.html) ``` -------------------------------- ### getTimeOf Source: https://github.com/ondras/rot.js/blob/master/doc/classes/scheduler_scheduler.default.html Gets the scheduled time of a specific item. ```APIDOC ## getTimeOf ### Description Gets the scheduled time of a specific item. ### Method getTimeOf(item: T) ### Parameters #### Parameters - **item** (T) - The item to get the scheduled time for. ### Returns undefined | number ``` -------------------------------- ### default Constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/display_display.default.html Initializes a new instance of the default display. Accepts optional display options to configure its behavior. ```APIDOC ## new default(options?: Partial): default ### Description Initializes a new instance of the default display class. You can provide partial display options to customize its behavior upon creation. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * **options** (Partial) - Optional - An object containing display configuration options. ### Request Example ```json { "options": { "width": 80, "height": 25, "fontSize": 16 } } ``` ### Response #### Success Response (200) * Returns an instance of the default display class. #### Response Example ```json { "instance": "[Display Instance]" } ``` ``` -------------------------------- ### A* Algorithm Pathfinding Source: https://github.com/ondras/rot.js/blob/master/manual/pages/path.html Demonstrates finding paths using A* algorithm. Requires a map generation, a passable callback, and then computes paths from multiple sources to a target. ```javascript var w = 150, h = 80; ROT.RNG.setSeed(12345); var display = new ROT.Display({width:w, height:h, fontSize:6}); SHOW(display.getContainer()); /* generate map and store its data */ var data = {}; var map = new ROT.Map.Uniform(w, h); map.create(function(x, y, value) { data[x+","+y] = value; display.DEBUG(x, y, value); }); /* input callback informs about map structure */ var passableCallback = function(x, y) { return (data[x+","+y] === 0); } /* prepare path to given coords */ var astar = new ROT.Path.AStar(98, 38, passableCallback); /* compute from given coords #1 */ astar.compute(8, 45, function(x, y) { display.draw(x, y, "", "", "#800"); }); /* compute from given coords #2 */ astar.compute(130, 8, function(x, y) { display.draw(x, y, "", "", "#800"); }); /* highlight */ display.draw(8, 45, "", "", "#3f3"); display.draw(130, 8, "", "", "#3f3"); display.draw(98, 38, "", "", "#f33"); ``` -------------------------------- ### get Source: https://github.com/ondras/rot.js/blob/master/doc/classes/noise_noise.default.html Generates a noise value at the specified coordinates. ```APIDOC ## get(x: number, y: number): number ### Description Generates a noise value at the specified coordinates. ### Parameters #### Path Parameters * **x** (number) - Description of x parameter * **y** (number) - Description of y parameter ### Returns number * A noise value at the given coordinates. ``` -------------------------------- ### getTime Source: https://github.com/ondras/rot.js/blob/master/doc/classes/scheduler_speed.default.html Gets the current time of the scheduler's event queue. ```APIDOC ## getTime ### Description Gets the current time of the scheduler's event queue. ### Method getTime ### Returns #### Success Response (200) - **number** - The current time. ### See ROT.EventQueue#getTime ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/engine.default.html Initializes a new instance of the default engine. It takes a scheduler as a parameter to manage asynchronous actions. ```APIDOC ## constructor ### Description Initializes a new instance of the default engine. It takes a scheduler as a parameter to manage asynchronous actions. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **scheduler** ([default](scheduler_scheduler.default.html)) - The scheduler to manage asynchronous actions. ### Returns * [default](engine.default.html) - A new instance of the default engine. ``` -------------------------------- ### getTime Source: https://github.com/ondras/rot.js/blob/master/doc/classes/eventqueue.default.html Gets the current elapsed time within the event queue. ```APIDOC ## getTime ### Description Gets the current elapsed time within the event queue. ### Method getTime(): number ### Returns number Elapsed time ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_rogue.default.html Initializes a new instance of the Rogue dungeon generator. It takes the desired width and height of the map, along with optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the Rogue dungeon generator. ### Method new ### Parameters #### Path Parameters - **width** (number) - Required - The width of the dungeon map. - **height** (number) - Required - The height of the dungeon map. - **options** (Partial) - Optional - Configuration options for the generator. ### Returns - **default** - An instance of the Rogue dungeon generator. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/scheduler_scheduler.default.html Initializes a new instance of the default scheduler class. ```APIDOC ## constructor ### Description Initializes a new instance of the default scheduler class. ### Method constructor ### Parameters None ### Returns [default](scheduler_scheduler.default.html) ``` -------------------------------- ### ROT.js Lighting Initialization and Computation Source: https://github.com/ondras/rot.js/blob/master/manual/pages/lighting.html This snippet demonstrates how to initialize and use the ROT.js Lighting module. It includes setting up map data, a FOV algorithm, reflectivity, light sources, and computing the final lighting. Use this for calculating light spread and color mixing in a cellular map. ```javascript ROT.RNG.setSeed(12345); var mapData = {}; var lightData = {}; var W = 60; var H = 40; /* build a map */ var map = new ROT.Map.Cellular(W, H).randomize(0.5); function createCallback(x, y, value) { mapData[x+","+y] = value; } for (var i=0; i<4; i++) { map.create(createCallback); } /* prepare a FOV algorithm */ function lightPasses(x, y) { return (mapData[x+","+y] == 1); } var fov = new ROT.FOV.PreciseShadowcasting(lightPasses, {topology:4}); /* prepare a lighting algorithm */ function reflectivity(x, y) { return (mapData[x+","+y] == 1 ? 0.3 : 0); } var lighting = new ROT.Lighting(reflectivity, {range:12, passes:2}); lighting.setFOV(fov); lighting.setLight(12, 12, [240, 240, 30]); lighting.setLight(20, 20, [240, 60, 60]); lighting.setLight(45, 25, [200, 200, 200]); function lightingCallback(x, y, color) { lightData[x+","+y] = color; } lighting.compute(lightingCallback); ``` -------------------------------- ### Simplex Noise Get Method Source: https://github.com/ondras/rot.js/blob/master/doc/classes/noise_simplex.default.html Generates simplex noise at a given 2D coordinate. ```APIDOC ## get(x: number, y: number): number ### Description Generates simplex noise at a given 2D coordinate. ### Parameters #### Parameters - **x** (number) - The x-coordinate. - **y** (number) - The y-coordinate. ### Returns - **number** - The generated noise value. ``` -------------------------------- ### Room Constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Room.html Initializes a new Room instance. It defines the boundaries of the room and optionally a door's position. ```APIDOC ## constructor Room ### Description Initializes a new Room instance with specified coordinates and optional door position. ### Parameters * **x1** (number) - The starting x-coordinate of the room. * **y1** (number) - The starting y-coordinate of the room. * **x2** (number) - The ending x-coordinate of the room. * **y2** (number) - The ending y-coordinate of the room. * **doorX** (number) - Optional. The x-coordinate of the door. * **doorY** (number) - Optional. The y-coordinate of the door. ### Returns [Room](map_features.Room.html) - The newly created Room instance. ``` -------------------------------- ### Basic String Formatting Source: https://github.com/ondras/rot.js/blob/master/manual/pages/format.html Demonstrates the basic usage of ROT.Util.format with simple string arguments. ```javascript SHOW( ROT.Util.format("%s %s", "hello", "world") ); ``` -------------------------------- ### get Source: https://github.com/ondras/rot.js/blob/master/doc/classes/eventqueue.default.html Retrieves and removes the next available event from the queue, advancing the internal time if necessary. ```APIDOC ## get ### Description Retrieves and removes the next available event from the queue, advancing the internal time if necessary. ### Method get(): null | T ### Returns null | T The event previously added by addEvent, null if no event available ``` -------------------------------- ### _castVisibility Source: https://github.com/ondras/rot.js/blob/master/doc/classes/fov_recursive_shadowcasting.default.html Recursively casts visibility from a starting point to determine visible areas within a given radius and slope. ```APIDOC ## _castVisibility ### Description This method recursively calculates visibility from a given point. It's used internally to implement the shadowcasting algorithm. ### Method _castVisibility(startX: number, startY: number, row: number, visSlopeStart: number, visSlopeEnd: number, radius: number, xx: number, xy: number, yx: number, yy: number, callback: VisibilityCallback): void ### Parameters #### Parameters - **startX** (number) - Required - The starting X coordinate for the visibility cast. - **startY** (number) - Required - The starting Y coordinate for the visibility cast. - **row** (number) - Required - The current row being processed. - **visSlopeStart** (number) - Required - The starting slope for the current visibility arc. - **visSlopeEnd** (number) - Required - The ending slope for the current visibility arc. - **radius** (number) - Required - The maximum distance to cast visibility. - **xx** (number) - Required - Transformation matrix component. - **xy** (number) - Required - Transformation matrix component. - **yx** (number) - Required - Transformation matrix component. - **yy** (number) - Required - Transformation matrix component. - **callback** (VisibilityCallback) - Required - A callback function executed for each visible cell. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/eventqueue.default.html Initializes a new instance of the EventQueue class. ```APIDOC ## constructor ### Description Initializes a new instance of the EventQueue class. ### Method constructor ### Returns [default](eventqueue.default.html) ### Type parameters * #### T = any ``` -------------------------------- ### compute Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_astar.default.html Computes the shortest path from the starting point to the target destination using the A* algorithm. It returns an array of coordinates representing the path. ```APIDOC ## compute ### Description Computes the shortest path from the starting point to the target destination using the A* algorithm. It returns an array of coordinates representing the path. ### Method compute(fromX: number, fromY: number): Array<[number, number]> ### Parameters #### Path Parameters * **fromX** (number) - The starting x-coordinate. * **fromY** (number) - The starting y-coordinate. ### Returns Array<[number, number]> - An array of [x, y] coordinates representing the path from start to end. Returns an empty array if no path is found. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_arena.default.html Initializes a new instance of the default class. It inherits from the default class in map/map and can take optional width and height parameters. ```APIDOC ## constructor ### Description Initializes a new instance of the default class. It inherits from the default class in map/map and can take optional width and height parameters. ### Method constructor ### Parameters #### Path Parameters * **width** (number) - Optional - Default: DEFAULT_WIDTH * **height** (number) - Optional - Default: DEFAULT_HEIGHT #### Returns [default](map_arena.default.html) ``` -------------------------------- ### randomize Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_cellular.default.html Fills the map with random values based on a given probability. This is often used as a starting point for cellular automaton generation. ```APIDOC ## randomize ### Description Fills the map with random values based on a given probability. This is often used as a starting point for cellular automaton generation. ### Parameters #### Parameters * **probability** (number) - The probability (0 to 1) of a cell being set to a specific value (usually 1). * **value** (number) - The value to set for cells that meet the probability criteria. Defaults to 1. ``` -------------------------------- ### Basic EventQueue Usage Source: https://github.com/ondras/rot.js/blob/master/manual/pages/timing/eventqueue.html Demonstrates adding events with priorities, removing an event, and retrieving events and elapsed time. ```javascript var queue = new ROT.EventQueue(); queue.add("event 1", 100); /* queued after 100 time units */ queue.add("event 2", 10); /* queued after 10 time units */ queue.add("event 3", 50); /* queued after 50 time units */ queue.remove("event 2"); SHOW( queue.get(), queue.get(), queue.getTime() ); ``` -------------------------------- ### create Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_features.Room.html Creates the room by calling a dig callback for each cell within its boundaries. ```APIDOC ## create ### Description Generates the room's structure by invoking a callback function for each cell, allowing for custom content placement (empty, wall, door). ### Parameters * **digCallback** (DigCallback) - A function with signature (x, y, value) that defines the content of each cell. Values: 0 = empty, 1 = wall, 2 = door. Multiple doors are allowed. ### Returns void ``` -------------------------------- ### getTime Source: https://github.com/ondras/rot.js/blob/master/doc/classes/scheduler_simple.default.html Gets the current time of the scheduler. This is useful for understanding the progression of scheduled events. This method is inherited from the base Scheduler class. ```APIDOC ## getTime ### Description Gets the current time of the scheduler. This is useful for understanding the progression of scheduled events. This method is inherited from the base Scheduler class. ### Method getTime ### Returns - number - The current time of the scheduler. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_astar.default.html Initializes a new instance of the A* pathfinder. It requires the target coordinates, a callback function to determine passable cells, and optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the A* pathfinder. It requires the target coordinates, a callback function to determine passable cells, and optional configuration options. ### Method new default(toX: number, toY: number, passableCallback: [PassableCallback](../modules/path_path.html#PassableCallback), options?: Partial<[Options](../interfaces/path_path.Options.html)>): [default](path_astar.default.html) ### Parameters #### Path Parameters * **toX** (number) - The x-coordinate of the target destination. * **toY** (number) - The y-coordinate of the target destination. * **passableCallback** ([PassableCallback](../modules/path_path.html#PassableCallback)) - A function that returns true if a cell is passable, false otherwise. * **options** (Partial<[Options](../interfaces/path_path.Options.html) angle) - Optional configuration for the pathfinder. Defaults to an empty object. ### Returns [default](path_astar.default.html) - An instance of the A* pathfinder. ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_dividedmaze.default.html Initializes a new instance of the default class, which is a map generator. It can take optional width and height parameters. ```APIDOC ## constructor ### Description Initializes a new instance of the default class, which is a map generator. It can take optional width and height parameters. ### Method constructor ### Parameters * **width** (number) - Optional - The width of the map. * **height** (number) - Optional - The height of the map. ### Returns * **default** - An instance of the default class. ``` -------------------------------- ### compute Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_astar.default.html Computes a path from a given point using the AStar algorithm. It takes starting coordinates and a callback function to determine path validity. ```APIDOC ## compute ### Description Computes a path from a given point using the AStar algorithm. It takes starting coordinates and a callback function to determine path validity. ### Method compute ### Parameters #### Path Parameters - **fromX** (number) - The starting X coordinate. - **fromY** (number) - The starting Y coordinate. - **callback** (ComputeCallback) - A function that returns true if a cell is passable. ### Returns void ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/fov_precise_shadowcasting.default.html Initializes a new instance of the Precise Shadowcasting FOV algorithm. It inherits from the base FOV class and requires a callback to determine light passage and accepts optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the Precise Shadowcasting FOV algorithm. It inherits from the base FOV class and requires a callback to determine light passage and accepts optional configuration options. ### Method constructor ### Parameters #### Parameters - **lightPassesCallback**: [LightPassesCallback] - Required - Determines if light passes through the given coordinates (x, y). - **options**: Partial<[Options]> - Optional - Configuration options for the FOV algorithm. ``` -------------------------------- ### getSpeed Source: https://github.com/ondras/rot.js/blob/master/doc/interfaces/scheduler_speed.SpeedActor.html Retrieves the current speed of the actor. This method is part of the SpeedActor interface and is used to determine how frequently an actor gets a turn in the scheduler. ```APIDOC ## getSpeed ### Description Retrieves the current speed of the actor. This method is part of the SpeedActor interface and is used to determine how frequently an actor gets a turn in the scheduler. ### Method getSpeed() ### Returns number - The current speed of the actor. ``` -------------------------------- ### Create a ROT.js Display Source: https://github.com/ondras/rot.js/blob/master/manual/pages/display.html Initializes a new ROT.js display instance with specified dimensions. Remember to append the display's container to the DOM. ```javascript var display = new ROT.Display({width:20, height:5}); SHOW(display.getContainer()); /* do not forget to append to page! */ ``` -------------------------------- ### constructor Source: https://github.com/ondras/rot.js/blob/master/doc/classes/fov_discrete_shadowcasting.default.html Initializes a new instance of the Discrete Shadowcasting FOV algorithm. It inherits from the base FOV class and requires a callback function to determine light passability and accepts optional configuration options. ```APIDOC ## constructor ### Description Initializes a new instance of the Discrete Shadowcasting FOV algorithm. It inherits from the base FOV class and requires a callback function to determine light passability and accepts optional configuration options. ### Method constructor ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Parameters * **lightPassesCallback**: [LightPassesCallback](../interfaces/fov_fov.LightPassesCallback.html) - Required - Determines if light passes through a given coordinate (x, y). * **options**: Partial<[Options](../interfaces/fov_fov.Options.html) angle - Optional - Configuration options for the FOV algorithm. ``` -------------------------------- ### _compute Source: https://github.com/ondras/rot.js/blob/master/doc/classes/path_dijkstra.default.html Computes the shortest path from a starting point to the target coordinates using the Dijkstra algorithm. This method is intended for internal use and handles the core pathfinding logic. ```APIDOC ## _compute ### Description Computes the shortest path from a starting point to the target coordinates using the Dijkstra algorithm. This method is intended for internal use and handles the core pathfinding logic. ### Method _compute(fromX: number, fromY: number): void ### Parameters #### Path Parameters * **fromX** (number) - The starting X coordinate. * **fromY** (number) - The starting Y coordinate. ### Returns void ``` -------------------------------- ### getOptions() Source: https://github.com/ondras/rot.js/blob/master/doc/classes/display_display.default.html Retrieves the current options configured for the display. ```APIDOC ## getOptions() ### Description Returns currently set options. ### Returns [DisplayOptions](../interfaces/display_types.DisplayOptions.html) ``` -------------------------------- ### Field of View with Hexagonal Topology Source: https://github.com/ondras/rot.js/blob/master/manual/pages/hex/about.html Enable hexagonal topology for the `ROT.FOV.PreciseShadowcasting` algorithm by specifying `topology:6`. This example generates a map, defines a light-passing callback, and computes the FOV. ```javascript ROT.RNG.setSeed(12345); var W = 44; var H = 28; var display = new ROT.Display({fontSize:12, layout:"hex", width:W, height:H}); SHOW(display.getContainer()); /* generate map and store its data */ var data = {}; var map = new ROT.Map.Cellular(W, H, { topology: 6, born: [4, 5, 6], survive: [3, 4, 5, 6] }); map.randomize(0.4); map.create(function(x, y, value) { data[x+","+y] = value; display.DEBUG(x, y, value); }); /* input callback */ function lightPasses(x, y) { var key = x+","+y; if (key in data) { return (data[key] == 0); } return false; } var fov = new ROT.FOV.PreciseShadowcasting(lightPasses, {topology:6}); /* output callback */ fov.compute(20, 14, 6, function(x, y, r, vis) { var ch = (r ? "" : "@"); var color = (data[x+","+y] ? "#aa0": "#660"); display.draw(x, y, ch, "#fff", color); }); ``` -------------------------------- ### Node.js Display Initialization and Drawing Source: https://github.com/ondras/rot.js/blob/master/README.md Initializes a ROT.Display instance for terminal layout in Node.js and demonstrates drawing characters with foreground and background colors. ```javascript let 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 ``` -------------------------------- ### Generate Normal Distribution Histogram Source: https://github.com/ondras/rot.js/blob/master/manual/pages/rng.html Generates a histogram of normally distributed random numbers to visualize the distribution. This example uses ROT.RNG.getNormal() to generate data points and then plots them on a canvas. ```javascript var canvas = document.createElement("canvas"); canvas.width = 500; canvas.height = 200; SHOW(canvas); var ctx = canvas.getContext("2d"); ctx.fillStyle = "#fff"; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = "#f00"; var data = []; for (var i=0;i<40000;i++) { /* generate histogram */ var num = Math.round(ROT.RNG.getNormal(250, 100)); data[num] = (data[num] || 0) + 1; } for (var i=0;i) - Optional - Configuration options for the StringGenerator. ### Response #### Success Response (200) * **Instance of default** - A new StringGenerator instance. ### Response Example ```json { "example": "new default(options)" } ``` ``` -------------------------------- ### create Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_uniform.default.html Creates a map using the Uniform algorithm. Returns null if the time limit is hit. ```APIDOC ## create ### Description Creates a map using the Uniform algorithm. If the time limit has been hit, returns null. ### Method N/A (Static Method) ### Parameters #### Path Parameters - **callback** (CreateCallback) - Optional - A callback function to be executed during map creation. ### Returns - **null | default** - The generated map object, or null if the time limit was exceeded. ``` -------------------------------- ### Speed Scheduler Example Source: https://github.com/ondras/rot.js/blob/master/manual/pages/timing/scheduler.html Illustrates ROT.Scheduler.Speed for scheduling actors based on their relative speed. Actors must implement a getSpeed() method. Use for games where actor speed influences turn frequency. ```javascript var scheduler = new ROT.Scheduler.Speed(); /* generate some actors */ for (var i=0;i<4;i++) { var actor = { speed: ROT.RNG.getPercentage(), number: i+1, getSpeed: function() { return this.speed; } } scheduler.add(actor, true); SHOW(ROT.Util.format("Object #%s has speed %s.", actor.number, actor.speed)); } /* simulate several turns */ var turns = []; for (var i=0;i<40;i++) { var current = scheduler.next(); turns.push(current.number); } SHOW("\nGenerated order of turns:"); SHOW(turns.join(" ") + " ..."); ``` -------------------------------- ### Cellular Dungeon Generator in Hexagonal Mode Source: https://github.com/ondras/rot.js/blob/master/manual/pages/hex/about.html Enable hexagonal mode for the `ROT.Map.Cellular` generator by passing `topology:6` to its constructor. This example initializes the map with irregularly random values and generates four iterations. ```javascript var w = 100, h = 50; var display = new ROT.Display({width:w, height:h, fontSize:10, layout:"hex"}); SHOW(display.getContainer()); /* hexagonal map and rules */ var map = new ROT.Map.Cellular(w, h, { topology: 6, born: [4, 5, 6], survive: [3, 4, 5, 6] }); /* initialize with irregularly random values */ for (var i=0; i=0; i--) { map.create(i ? null : display.DEBUG); } ``` -------------------------------- ### create Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_digger.default.html Generates a dungeon map based on the configured options and dimensions. ```APIDOC ## create ### Description Generates a dungeon map based on the configured options and dimensions. ### Signature `create(): void` ### Returns `void` ``` -------------------------------- ### _firstRoom Source: https://github.com/ondras/rot.js/blob/master/doc/classes/map_digger.default.html Initializes the map by creating the first room. This is an internal method used at the beginning of map generation. ```APIDOC ## _firstRoom ### Description Creates the first room on the map. ### Method (): void ### Returns void ```