I really hated that ugly array of arrays.
Here's a simpler way to do it, I think:
Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>met@verse Test</title>
<style type="text/css">
#myMap {
font-family: courier;
font-size: x-large;
}
</style>
</head>
<body>
<div id="myMap"></div>
<script type="text/javascript">
(
function()
{
var map = [
"#####",
"#...#",
"#...#",
"#...#",
"#####"
];
function replaceCharAt( str, char, at )
{
var temp = str.split("");
temp[at] = char;
return temp.join("");
}
function plotCurrentLocation( x, y )
{
// clone the master map
var useMap = [].concat(map);
// replace the appropriate character in the appropriate row:
useMap[y] = replaceCharAt( useMap[y], "@", x );
// dump it all out as a single string to the div's contents:
document.getElementById("myMap").innerHTML =
useMap.join("<br/>");
}
// demo that it works
var userx = 3;
var usery = 2;
plotCurrentLocation( userx, usery );
}
)();
</script>
</body>
</html>