UNPKG

@nichathan-gaming/map-generator

Version:

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

18 lines (15 loc) 640 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 vertically through the map * @param {mapGenerator} map The current game map element * @param {number} width The maximum range for moving horizontally */ const crawlVertically = (map, width) => { assertInstanceOf(map, mapGenerator); assertType(width, basicTypes.number); crawl(map, [getRandomRange(1, width) , 1], [-1, 0]); }; export default crawlVertically;