Maze Automata
A generative maze that builds itself in real-time.
60 FPS • p5.js
p5.js Sketch Code
p.setup = () => {
p.createCanvas(p.container.clientWidth, p.container.clientHeight);
p.background(20);
p.stroke(255);
};
let x = 0, y = 0, spacing = 20;
p.draw = () => {
if (p.random(1) < 0.5) p.line(x, y, x + spacing, y + spacing);
else p.line(x, y + spacing, x + spacing, y);
x += spacing;
if (x > p.width) { x = 0; y += spacing; }
if (y > p.height) { p.background(20); x = 0; y = 0; }
};
p.windowResized = () => { if(p.container) p.resizeCanvas(p.container.clientWidth, p.container.clientHeight); }; Properties
#p5js#maze#automata
Author: Math Art Core Target: 60 FPS