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

beta.r3js.org
-=yb4f310 2018-03-12 14:55:38 +01:00
parent 42e335fc2c
commit b8ebf39eb8
1 changed files with 19 additions and 6 deletions

View File

@ -71,23 +71,36 @@ GameLib.CustomCode.prototype.initializeGrid = function() {
GameLib.CustomCode.prototype.cloneBody = function(bodyType) { GameLib.CustomCode.prototype.cloneBody = function(bodyType) {
var body = null; var mesh = null;
switch (bodyType) { switch (bodyType) {
case (GameLib.CustomCode.BODY_TYPE_HEAD) : case (GameLib.CustomCode.BODY_TYPE_HEAD) :
body = this.meshEnd.clone(); mesh = this.meshEnd.clone();
break; break;
case (GameLib.CustomCode.BODY_TYPE_TAIL) : case (GameLib.CustomCode.BODY_TYPE_TAIL) :
body = this.meshEnd.clone(); mesh = this.meshEnd.clone();
body.rotation.z = Math.PI; mesh.rotation.z = Math.PI;
body.updateInstance('rotation'); mesh.updateInstance('rotation');
break; break;
default: default:
console.warn('unhandled body type : ' + bodyType); console.warn('unhandled body type : ' + bodyType);
break; break;
} }
return body; var direction = {
x : -1,
y : 0
};
if (this.snake.length > 0) {
direction.x = this.snake[0].direction.x;
direction.y = this.snake[0].direction.y;
}
return {
mesh : body,
direction : direction
}
}.bind(this); }.bind(this);