我正在制作一个基本游戏,现在我正在进行碰撞检查。我从一个数组加载我的mapp,但我被困在绘制它的代码上。
加载数组:
var levelArray=[
[1,0,0,0,0,0,0,0,0,1],
[1,0,2,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,0,0,0,0,0,0,0,0,1],
[1,1,1,1,1,1,1,1,1,1]
]
这是我尝试绘制块(1)的代码。
for(arrayx=0;arrayx<11;arrayx++){
if (levelArray[arrayx][arrayy]==1){
canvas_context.fillStyle = "blue";
canvas_context.fillRect(arrayx*32,arrayy*32,32,32);
}
if (arrayx==10 && arrayy<11){
arrayy++
}
}
有人可以帮助我并告诉我哪里出错了吗?