Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 204 bytes modified
parent
42e335fc2c
commit
b8ebf39eb8
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue