How to use the rot-js.Map function in rot-js

To help you get started, we’ve selected a few rot-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seiyria / Roguathia / src / js / rogue / worldgen / maptypes / dungeon.js View on Github external
static generate(opts) {
    const { w, h, z } = opts;
    const map = [];
    
    // -3 to adjust for the UI components at the bottom
    const digger = new ROT.Map.Digger(w, h-3, { roomWidth: [4, 8], roomHeight: [4, 7], corridorLength: [5, 13], dugPercentage: 0.3 });
    
    digger.create((x, y, value) => {
      if(!map[x]) map[x] = [];

      let proto = Tiles.Void;
      if(!value) proto = Tiles.DungeonFloor;
      
      this.placeTile(map, proto, x, y, z);
    });
    
    // replace all corridors with corridor tiles
    _.each(digger.getCorridors(), (corridor) => {
      this.placeCorridorTiles(map, corridor, z);
    });

    const rooms = digger.getRooms();
github MattMcFarland / rot-web-api / index.js View on Github external
function rogueApi (req, res, ctx, done) {
  const ROT = require('rot-js')
  const querystring = require('querystring')
  try {
    const queryParams = querystring.parse(req.url.split('?')[1]) || {}
    const method = translateMethod(ctx.params.method)
    const gen = ROT.Map[method]
    const options = Object.assign({}, { width: 80, height: 25 }, queryParams)

    let rogueMap;
    let map = []
    rogueMap = new gen(options.height, options.width, options).create((x, y, v) => {
      map[x] = map[x] || []
      map[x][y] = v
    })
    done(null, Object.assign({}, {map}, rogueMap))
  } catch (e) {
    app.log.error(e)
    done(e)
  }
}
github seiyria / Roguathia / src / js / rogue / worldgen / maptypes / altar.js View on Github external
static generate(opts) {
    const { w, h, z } = _.extend({ w: 15, h: 15 }, opts);
    const map = [];
    
    const arena = new ROT.Map.Arena(w, h);
    
    arena.create((x, y, value) => {
      if(!map[x]) map[x] = [];

      let proto = Tiles.Void;
      if(!value) proto = Tiles.DungeonFloor;
      
      this.placeTile(map, proto, x, y, z);
    });

    const room = new ROT.Map.Feature.Room(1, 1, w-2, h-2);

    this.drawVerticalWalls(map, room, z);
    this.drawHorizontalWalls(map, room, z);

    const stairs = [
github Larkenx / Rotten-Soup / src / assets / js / game / map / generation / RandomDungeon.js View on Github external
return tryButCatchRotException(() =>
			dungeonFromTheme(width, height, dungeonThemes.MINE, new ROT.Map.Uniform(width, height, dc), options, false)
		)
github seiyria / Roguathia / src / js / rogue / worldgen / maptypes / altar.js View on Github external
static generate(opts) {
    const { w, h, z } = _.extend({ w: 15, h: 15 }, opts);
    const map = [];
    
    const arena = new ROT.Map.Arena(w, h);
    
    arena.create((x, y, value) => {
      if(!map[x]) map[x] = [];

      let proto = Tiles.Void;
      if(!value) proto = Tiles.DungeonFloor;
      
      this.placeTile(map, proto, x, y, z);
    });

    const room = new ROT.Map.Feature.Room(1, 1, w-2, h-2);

    this.drawVerticalWalls(map, room, z);
    this.drawHorizontalWalls(map, room, z);

    const stairs = [
      this.placeStairsInRoom(map, room, z, Tiles.StairsUp)
    ];

    const altarTile = this.getRandomFloorTile(map);
    this.placeTile(map, Tiles.SelykAltar, altarTile.x, altarTile.y, z);
    
    return { map, stairs, rooms: [room], mapName: `Selyk's Altar`, shortMapName: 'Altar' };
  }
}