UNPKG

3.6 kBMarkdownView Raw
1# nylira-maze
2
3A JavaScript library for generating maze data.
4
5 _________________________________________________________________________________
6 | | ________ | ________ | |__ |______ | | ____ | | | | | __ |
7 |___|____ | | | | __ |____ |_____|______ _| | | |_|__ | | |_|___| | | | | | |
8 | __ __ | | |____ |____ |_| ____ __ | | ___| | | |_| |__________ |___| | |
9 |_| _|_____| | ___| | ___| | | | | | |__ _| | |_____| | __ _| | ___| |
10 | _| | ___|_______|_|_____| | |___| |_|_____| _| |___________|_____|_______|
11 | ___| | | | | ________ _|______ | _| | | | | ______ | ____ | ____ |
12 | |__ | | | | | | | __ | | | |_______| _| | | | | | ___| | |__ | | |__ | |
13 | ___| | |___|___| | _| |_|___|___________| _| | | | |____ |___| _| |__ _| |
14 | | ___|___________|___|__________________ | _____| | | |____ | |__ | | _|
15 | | |______ |__ | __ | _____| ___| | | | | | | | |___|__ |___|__ |
16 | | |_________|_____| |___| | |_________| ___| | | |_____| | | | | _______| |
17 | |____ | | | _________| | ____ |____ | | |______ |___|___|_______| | |
18 | _| _| | | |_|__ | __ _| | | ___|__ |___| |____ | | ________ _____| | |
19 |__ | |___|__ __ | | | | _|_|__ |___|__ | | | | | | | | |_| | | |
20 | _| | _______|___| | | |____ | _|______ | _| | | |__ | |_|___| | | |_|__ |
21 |__ | |_____| _______| |__ _| |___| __ | |__ |___|__ | |__ | ___| |_| | ___|
22 | | | | __ |________ | |___| _| | | | |__ | | _____|_____|__ |_______| | |
23 |___|_____|___________|___________|___|_______|___|_________________________|___|
24
25## Installation
26
27 npm i nylira-maze --save
28
29## Usage
30
31Basic usage:
32
33 var maze = require('nylira-maze')
34
35 // returns a 2d array of values for a 10x10 maze
36 maze()
37
38 // returns a 2d array of values for a 20x20 maze
39 maze(20)
40
41 // returns a 2d array of values for a 20x20 maze
42 maze(15, 23)
43
44# Parameters
45
46Keep reading to learn about the function call below:
47
48 maze(17, 23, 'backtracker', undefined, true)
49
50* **Parameter 1:** Width.
51* **Parameter 2:** Height.
52* **Parameter 3:** The maze generation algorithm. Currently only Recursive Backtracker is available (`'backtracker'`).
53* **Parameter 4:** The integer seed for the maze. Putting a value here will guaranteee you can recreate the maze over and over again.
54* **Parameter 5:** You can preview the grid by passing in `true` as the fifth parameter.
55
56That function call above will generate the following:
57
58 ___________________________________
59 | | __ _________| ______ | __ |
60 | |___|____ | __ |______ | | | | |
61 |____ |__ | | | ____ |___|__ | | |
62 | |____ | | | | |______ | | | |
63 | |__ | _| | | | |_____| _|___| |
64 | | _| | _| | |______ | | | |
65 | | | | |_____| | | __ | | | |___|
66 |_| | |_________|_____|__ |_|____ |
67 | | __ __ | ______ | | | |
68 | | |__ | |_____| _____| |_| | | |
69 | |_____|____ | |__ | | | _| _|
70 |____ | ___| | _| | | | |__ | | |
71 | _|____ | _|_____| | | | _| | |
72 |____ | |______ ___| | | | | | |
73 | | _|____ |_| | |___| | | |
74 | | | |__________ | |_| | _____| |
75 | | | | | _| |__ |___|__ _|
76 | | |___| | | | _| _| | _|__ |
77 |_| |__ | | |_| | |__ | | |____ | |
78 | _| _| _| |__ | | |____ | |_|
79 |__ |______ | |_________| | _| |
80 | _| |_| | | _| | | _| |
81 |_____|_|_____|___|_____|_____|___|
82
83## Test
84
85See if it works.
86
87 npm test
88
89## License
90
91MIT