所以在我看来,这段代码看起来不错,但我不能说它是否好,因为它冻结了整个绘画循环。之前它工作得很好,没有所有的抵消麻烦。
int offsetX = 0;
int offsetY = 0;
for(int y = 0, canvasY = offsetY + y, x = 0, canvasX = offsetX + x; canvasY < mapHeight + offsetY && canvasX < mapWidth + offsetX; y++, x++) {
int tileToPaint = canvasX + (canvasY * mapWidth);
tileObject = getObject(tileToPaint);
int locationX = tileSize * x;
int locationY = tileSize * y;
draw(tileObject, locationX, locationY);
}