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

beta.r3js.org
-=yb4f310 2018-03-12 14:51:24 +01:00
parent 32999117e4
commit 42e335fc2c
1 changed files with 25 additions and 6 deletions

View File

@ -44,12 +44,31 @@ this.scene = GameLib.EntityManager.Instance.findComponentById('pllp034hsj');
* Game objects
*/
this.snake = [];
this.grid = [[]];
this.grid = [];
GameLib.CustomCode.prototype.advanceSnake = function(delta) {
}.bind(this);
GameLib.CustomCode.prototype.initializeGrid = function() {
this.grid = [];
for (var x = 0; x < GameLib.CustomCode.GRID_WIDTH; x++) {
this.grid[x] = [];
for (var y = 0; y < GameLib.CustomCode.GRID_HEIGHT; y++) {
this.grid[x][y] = {
mesh : null,
direction : {
x : 0,
y : 0
}
}
}
}
}.bind(this);
GameLib.CustomCode.prototype.cloneBody = function(bodyType) {
var body = null;
@ -131,6 +150,9 @@ GameLib.Event.Subscribe(
this.cloneBody(GameLib.CustomCode.BODY_TYPE_TAIL)
];
/**
* Cleanup grid
*/
this.grid.map(
function(x) {
x.map(
@ -138,16 +160,13 @@ GameLib.Event.Subscribe(
y.mesh.geometry = null;
y.mesh.materials = null;
y.mesh.remove();
y.taken = false;
y.direction = {
x:0,
y:0
}
}
);
}
);
this.initializeGrid();
this.beforeRender.initialized = false;
this.beforeRender.entityLoaded = this;