Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 170 bytes modified
parent
f6692a3dc4
commit
4d65e5c696
|
@ -330,13 +330,28 @@ GameLib.CustomCode.GameObject.prototype.applyToMesh = function(updateInstance) {
|
|||
*/
|
||||
GameLib.CustomCode.prototype.getFreeGridPosition = function() {
|
||||
|
||||
var x = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_WIDTH);
|
||||
var y = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_HEIGHT);
|
||||
var positions = [];
|
||||
|
||||
return {
|
||||
this.grid.map(
|
||||
function(row, x) {
|
||||
row.map(
|
||||
function(object, y) {
|
||||
if (object.objectType === GameLib.CustomCode.OBJECT_TYPE_NONE) {
|
||||
positions.push(
|
||||
{
|
||||
x : x,
|
||||
y : y
|
||||
};
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
var index = GameLib.Utils.GetRandomInt(0, positions.length);
|
||||
|
||||
return positions[index];
|
||||
|
||||
}.bind(this);
|
||||
|
||||
|
|
Loading…
Reference in New Issue