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() {
|
GameLib.CustomCode.prototype.getFreeGridPosition = function() {
|
||||||
|
|
||||||
var x = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_WIDTH);
|
var positions = [];
|
||||||
var y = GameLib.Utils.GetRandomInt(0, GameLib.CustomCode.GRID_HEIGHT);
|
|
||||||
|
|
||||||
return {
|
this.grid.map(
|
||||||
x : x,
|
function(row, x) {
|
||||||
y : y
|
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);
|
}.bind(this);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue