mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 12:03:36 +00:00
18 lines
461 B
JavaScript
18 lines
461 B
JavaScript
|
var GetTilesWithin = require('./GetTilesWithin');
|
||
|
var ShuffleArray = require('../../../utils/array/Shuffle');
|
||
|
|
||
|
var Shuffle = function (tileX, tileY, width, height, layer)
|
||
|
{
|
||
|
var tiles = GetTilesWithin(tileX, tileY, width, height, layer);
|
||
|
|
||
|
var indices = tiles.map(function (tile) { return tile.index; });
|
||
|
ShuffleArray(indices);
|
||
|
|
||
|
for (var i = 0; i < tiles.length; i++)
|
||
|
{
|
||
|
tiles[i].index = indices[i];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = Shuffle;
|