Skip to content

Commit 4fa3dc7

Browse files
authored
Update CullTiles.js
1 parent e3d64c6 commit 4fa3dc7

1 file changed

Lines changed: 39 additions & 39 deletions

File tree

src/tilemaps/components/CullTiles.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,49 +42,49 @@ var CullTiles = function (layer, camera, outputArray)
4242
var boundsRight = SnapCeil(camera.worldView.right, tileW) + (tilemapLayer.cullPaddingX * tileW);
4343
var boundsTop = SnapFloor(camera.worldView.y, tileH) - (tilemapLayer.cullPaddingY * tileH);
4444
var boundsBottom = SnapCeil(camera.worldView.bottom, tileH) + (tilemapLayer.cullPaddingY * tileH);
45-
46-
// If skipping cull, loop through every tile in the map.
47-
48-
if(tilemapLayer.skipCull)
49-
{
50-
for (var y = 0; y < mapHeight; y++)
51-
{
52-
for (var x = 0; x < mapWidth; x++)
53-
{
54-
var tile = mapData[y][x];
45+
46+
// If skipping cull, loop through every tile in the map.
47+
48+
if(tilemapLayer.skipCull)
49+
{
50+
for (var y = 0; y < mapHeight; y++)
51+
{
52+
for (var x = 0; x < mapWidth; x++)
53+
{
54+
var tile = mapData[y][x];
5555

56-
if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
57-
{
58-
continue;
59-
}
56+
if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
57+
{
58+
continue;
59+
}
6060

61-
outputArray.push(tile);
62-
}
63-
}
64-
}
65-
else
66-
{
67-
var drawLeft = Math.max(0, boundsLeft / layer.tileWidth);
68-
var drawRight = Math.min(mapWidth, boundsRight / layer.tileWidth);
69-
var drawTop = Math.max(0, boundsTop / layer.tileHeight);
70-
var drawBottom = Math.min(mapHeight, boundsBottom / layer.tileHeight);
71-
72-
for (var y = drawTop; y < drawBottom; y++)
73-
{
74-
for (var x = drawLeft; x < drawRight; x++)
75-
{
76-
var tile = mapData[y][x];
61+
outputArray.push(tile);
62+
}
63+
}
64+
}
65+
else
66+
{
67+
var drawLeft = Math.max(0, boundsLeft / layer.tileWidth);
68+
var drawRight = Math.min(mapWidth, boundsRight / layer.tileWidth);
69+
var drawTop = Math.max(0, boundsTop / layer.tileHeight);
70+
var drawBottom = Math.min(mapHeight, boundsBottom / layer.tileHeight);
71+
72+
for (var y = drawTop; y < drawBottom; y++)
73+
{
74+
for (var x = drawLeft; x < drawRight; x++)
75+
{
76+
var tile = mapData[y][x];
7777

78-
if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
79-
{
80-
continue;
81-
}
78+
if (!tile || tile.index === -1 || !tile.visible || tile.alpha === 0)
79+
{
80+
continue;
81+
}
8282

83-
outputArray.push(tile);
84-
}
85-
}
86-
}
87-
83+
outputArray.push(tile);
84+
}
85+
}
86+
}
87+
8888
tilemapLayer.tilesDrawn = outputArray.length;
8989
tilemapLayer.tilesTotal = mapWidth * mapHeight;
9090

0 commit comments

Comments
 (0)