UNPKG

@nichathan-gaming/map-generator

Version:

Creates and generates a 2 dimensional array with various path generation functions.

18 lines (15 loc) 647 B
import mapGenerator from "../mapGenerator.js"; import crawl from "./crawl.js"; import getRandomRange from "../helpers/getRandomRange.js"; import { assertInstanceOf, assertType, basicTypes } from "@nichathan-gaming/assertions"; /** * Crawls mostly horizontally through the map * @param {mapGenerator} map The current game map element * @param {number} height The maximum range for moving vertically */ const crawlHorizontally = (map, height) => { assertInstanceOf(map, mapGenerator); assertType(height, basicTypes.number); crawl(map, [1, getRandomRange(1, height)], [0, -1]); }; export default crawlHorizontally;