——由 Elliot B 解决。谢谢!也可以考虑其他修改。
这是结果。谢谢大家,快速解答!http://dl.dropbox.com/u/18785762/Rust/index.html
我正在用 javascript 编写游戏,我想将用于匹配块 ID 的文件保存在地图编译器的单独 .js 文件中,以便我可以轻松地编辑内容。但是,ID 存储在一个数组中,我似乎无法让它正确使用返回函数。有什么帮助吗?
drawmap.js:
function drawmap() {
var images = BlockID();
var level = [
"ssssssssssssssssssssss",
"sgggggggggCCCCCdddddss",
"ssssssssss sssssss"
];
var top = 100;
var left = 100;
var mytop = top;
var myleft = left;
for (y=0; y<level.length; ++y) {
var row = level[y];
for (x=0; x < row.length; ++x) {
var c = row.charAt(x);
if(c != ' ') {
img_create(images[c], mytop, myleft);
}
mytop += 13;
myleft += 27;
}
mytop = top + (y+1)*13;
myleft = left - (y+1)*27;
}
}
mapread.js:
function BlockID() {
var IDs = new Array();
images['s'] = "Images/Block_01.png";
images['g'] = "Images/Block_02.png";
images['C'] = "Images/Block_03.png";
images['d'] = "Images/Block_04.png";
return IDs;
}