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

beta.r3js.org
-=yb4f310 2018-03-12 20:54:46 +01:00
parent ceef0798c5
commit 600bc4b2cc
1 changed files with 20 additions and 20 deletions

View File

@ -94,9 +94,9 @@ this.meshBodyPatty = this.createGameMesh(this.imageBodyPatty);
GameLib.CustomCode.SnakeBody = function(
bodyType,
mesh,
position,
direction,
mesh
direction
) {
if (GameLib.Utils.UndefinedOrNull(position)) {
position = {
@ -115,35 +115,36 @@ GameLib.CustomCode.SnakeBody = function(
this.direction = direction;
if (GameLib.Utils.UndefinedOrNull(bodyType)) {
bodyType = GameLib.CustomCode.BODY_TYPE_HEAD;
throw new Error('no body type specified');
}
this.bodyType = bodyType;
if (GameLib.Utils.UndefinedOrNull(mesh)) {
switch (this.bodyType) {
case GameLib.CustomCode.BODY_TYPE_HEAD :
mesh = this.meshEnd;
break;
case GameLib.CustomCode.BODY_TYPE_TAIL :
mesh = this.meshEnd.clone();
mesh.rotation.z = Math.PI;
mesh.updateInstance('rotation');
position.x += 1;
default :
throw new Error('body type not specified and no mesh');
break;
}
throw new Error('no mesh specified');
}
this.mesh = mesh;
switch (this.bodyType) {
case GameLib.CustomCode.BODY_TYPE_HEAD :
mesh = this.meshEnd;
break;
case GameLib.CustomCode.BODY_TYPE_TAIL :
mesh = this.meshEnd.clone();
mesh.rotation.z = Math.PI;
mesh.updateInstance('rotation');
position.x += 1;
default :
throw new Error('unreachable statement');
break;
}
this.applyPositionToMesh();
};
GameLib.CustomCode.SnakeBody.prototype.clone = function() {
return new GameLib.CustomCode.SnakeBody(
this.bodyType,
this.mesh,
{
x : this.position.x,
y : this.position.y
@ -151,8 +152,7 @@ GameLib.CustomCode.SnakeBody.prototype.clone = function() {
{
x : this.direction.x,
y : this.direction.y
},
this.mesh
}
);
}