Skip to content

Commit a5fe4bb

Browse files
committed
Section 22: Abstracting Maze Dimensions
1 parent 558524f commit a5fe4bb

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

22-Javascript-with-the-Canvas-API/02-Maze copy/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Matter.js library
22
const { Engine, Render, Runner, World, Bodies } = Matter
33

4+
const cells = 5
45
const width = 600
56
const height = 600
67

@@ -31,10 +32,14 @@ World.add(world, walls)
3132

3233
// Maze generation
3334

34-
const grid = Array(3).fill(null).map(() => Array(3).fill(false))
35+
const grid = Array(cells)
36+
.fill(null)
37+
.map(() => Array(cells).fill(false))
3538

36-
const verticals = Array(3).fill(null).map(() => Array(2).fill(false))
39+
const verticals = Array(cells).fill(null).map(() => Array(cells - 1).fill(false))
3740

38-
const horizontals = Array(2).fill(null).map(() => Array(3).fill(false))
41+
const horizontals = Array(cells - 1)
42+
.fill(null)
43+
.map(() => Array(cells).fill(false))
3944

40-
console.log(verticals)
45+
console.log(horizontals)

22-Javascript-with-the-Canvas-API/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@ const grid = Array(3).fill(null)
5555
console.log(grid)
5656
```
5757

58-
## 9. 13 Verticals and Horizontals
58+
## 9. 13 Verticals and Horizontals
59+
60+
## 10. 14 Abstracting Maze Dimensions

0 commit comments

Comments
 (0)