Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 170 bytes modified

beta.r3js.org
-=yb4f310 2018-03-22 19:36:18 +01:00
parent f6692a3dc4
commit 4d65e5c696
1 changed files with 21 additions and 6 deletions

View File

@ -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 = [];
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 {
x : x,
y : y
};
return positions[index];
}.bind(this);