Skip to content

Instantly share code, notes, and snippets.

@ramayac
Created November 10, 2012 17:24
Show Gist options
  • Save ramayac/4051820 to your computer and use it in GitHub Desktop.
Save ramayac/4051820 to your computer and use it in GitHub Desktop.
Tiny Maze JS
<html>
<head>
<meta charset="utf-8">
<title>TinyMaze</title>
</head>
<body>
<div id="maze" style="line-height: 0.7; font-size: 15px;border-color: black; border-style: solid; border-width: 1px; overflow:hidden; width:600px; height: 500px;white-space: normal;word-break: normal; word-spacing: 0px;word-wrap: normal;"></div>
</body>
<script type="text/javascript">
//A silly character based random "maze" by @ramayac
var c = function () {
return Math.random() < 0.5 ? "/" : "\\"; //old school magic.
}
var charMaze = function() {
var row = "";
for(j = 0; j < 60; j++) {
for(i = 0; i < 150; i++ ) {
row += c()
};
row += "\n";
}
return row;
}
document.getElementById("maze").innerHTML = charMaze();
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment