2017-11-25 14:42:19 +00:00
|
|
|
var GetTilesWithin = require('./GetTilesWithin');
|
|
|
|
var WorldToTileX = require('./WorldToTileX');
|
|
|
|
var WorldToTileY = require('./WorldToTileY');
|
|
|
|
|
2017-11-26 00:03:21 +00:00
|
|
|
var GetTilesWithinWorldXY = function (worldX, worldY, width, height, filteringOptions, camera, layer)
|
2017-11-25 14:42:19 +00:00
|
|
|
{
|
|
|
|
// Top left corner of the rect, rounded down to include partial tiles
|
|
|
|
var xStart = WorldToTileX(worldX, true, camera, layer);
|
|
|
|
var yStart = WorldToTileY(worldY, true, camera, layer);
|
|
|
|
|
|
|
|
// Bottom right corner of the rect, rounded up to include partial tiles
|
|
|
|
var xEnd = Math.ceil(WorldToTileX(worldX + width, false, camera, layer));
|
|
|
|
var yEnd = Math.ceil(WorldToTileY(worldY + height, false, camera, layer));
|
|
|
|
|
2017-11-26 00:03:21 +00:00
|
|
|
return GetTilesWithin(xStart, yStart, xEnd - xStart, yEnd - yStart, filteringOptions, layer);
|
2017-11-25 14:42:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = GetTilesWithinWorldXY;
|