-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
40 lines (32 loc) · 993 Bytes
/
sketch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Maze from './maze.js';
import MazeRenderer from './maze-renderer.js';
import MazeAgentFactory from './maze-agent-factory.js';
let mazeGenerationDepthFirstSearch = function (P5) {
let maze;
let mazeRenderer;
let frameRateSlider;
let canvas;
P5.setup = function () {
maze = new Maze(P5, 20, 20, 15);
maze.addAgent(MazeAgentFactory.createAgent(P5, 0, 0, maze));
maze.addAgent(MazeAgentFactory.createAgent(P5, 19, 19, maze));
mazeRenderer = new MazeRenderer(P5, maze);
canvas = P5.createCanvas(maze.width, maze.height).parent(
'canvas-container'
);
frameRateSlider = P5.createSlider(1, 60, 10, 1)
.parent('settings-container')
.id('frameRateSlider');
P5.frameRate(frameRateSlider.value());
};
P5.draw = function () {
P5.frameRate(frameRateSlider.value());
P5.background(0);
maze.update();
mazeRenderer.draw();
};
};
new p5(
mazeGenerationDepthFirstSearch,
'maze-generation-depth-first-search'
);