var maps = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]];
var role = [3, 4];
function up(action){
if(action == 1) role[1]--;
if(action == 2) role[0]--;
if(action == 3) role[1]++;
if(action == 4) role[0]++;
var tmp = '';
console.clear();
for(var i = 0; i < maps.length; i++){
tmp = '';
for(var j = 0; j < maps[i].length; j++){
if(role[0] == i && role[1] == j){
tmp += '* ';
}else {
tmp += maps[i][j] + ' ';
}
}
console.log(tmp);
}
}
document.onkeydown=function(event){
var e = event || window.event || arguments.callee.caller.arguments[0];
if(e && e.keyCode==37){ // 左
up(1);
}
if(e && e.keyCode==38){ // 上
up(2);
}
if(e && e.keyCode==39){ // 右
up(3);
}
if(e && e.keyCode==40){ // 下
up(4);
}
};