ASCII Maze
by eulomelo
HTML
<!DOCTYPE HTML>
<html>
<head>
<title>UNICODE Maze</title>
<meta charset="UTF-8">
<style>
body{
display: grid;
place-items: center;
}
#Maze{
font-family: monospace;
font-size: 5px;
}
</style>
</head>
<body>
<h1> UNICODE Maze </h1>
<div id="Maze"></div>
</body>
<script>
//⬜
//⬛
let canvas = document.getElementById("Maze");
//Makes maze array into string
function string2Darray(array){
let arrayString = "";
for(let i = 0; i < array.length; i++){
for(let j = 0; j < array[i].length; j++){
arrayString += array[i][j];
}
arrayString += "\n";
}
return arrayString;
}
//Makes maze array
function makeMaze(size){
wall = "⬛";
pass = "⬜";
maze = [];
for(let i = 0; i < size; i++){
row = [];
for(let j = 0; j < size; j++){
row.push(wall);
}
maze.push(row);
}
return maze
}
maze = makeMaze(90);
for(let i = 0; i < 30; i++){
for(let j = 0; j < 30; j++){
let x = 3*i+1;
let y = 3*j+1;
maze[y][x] = "⬜";
let random = Math.random();
if(random < 0.45){
maze[y][x-1] = "⬜";
maze[y][x+1] = "⬜";
maze[y+1][x] = "⬜";
maze[y+1][x-1] = "⬜";
maze[y+1][x+1] = "⬜";
} else if(random < 0.9){
maze[y-1][x] = "⬜";
maze[y+1][x] = "⬜";
maze[y][x+1] = "⬜";
maze[y-1][x+1] = "⬜";
maze[y+1][x+1] = "⬜";
}else{
maze[y-1][x] = "⬜";
maze[y+1][x] = "⬜";
maze[y][x+1] = "⬜";
maze[y-1][x+1] = "⬜";
maze[y+1][x+1] = "⬜";
maze[y][x-1] = "⬜";
maze[y-1][x-1] = "⬜";
maze[y+1][x-1] = "⬜";
}
}
}
let x = 45;
let y = 45;
maze[x][y] = "🟥";
maze[y-1][x] = "⬜";
maze[y+1][x] = "⬜";
maze[y][x+1] =...