Created
November 10, 2012 17:24
-
-
Save ramayac/4051820 to your computer and use it in GitHub Desktop.
Tiny Maze JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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