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( GameLib.CustomCode.SnakeBody = function(
bodyType, bodyType,
mesh,
position, position,
direction, direction
mesh
) { ) {
if (GameLib.Utils.UndefinedOrNull(position)) { if (GameLib.Utils.UndefinedOrNull(position)) {
position = { position = {
@ -115,35 +115,36 @@ GameLib.CustomCode.SnakeBody = function(
this.direction = direction; this.direction = direction;
if (GameLib.Utils.UndefinedOrNull(bodyType)) { if (GameLib.Utils.UndefinedOrNull(bodyType)) {
bodyType = GameLib.CustomCode.BODY_TYPE_HEAD; throw new Error('no body type specified');
} }
this.bodyType = bodyType; this.bodyType = bodyType;
if (GameLib.Utils.UndefinedOrNull(mesh)) { if (GameLib.Utils.UndefinedOrNull(mesh)) {
throw new Error('no mesh specified');
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;
}
} }
this.mesh = mesh; 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(); this.applyPositionToMesh();
}; };
GameLib.CustomCode.SnakeBody.prototype.clone = function() { GameLib.CustomCode.SnakeBody.prototype.clone = function() {
return new GameLib.CustomCode.SnakeBody( return new GameLib.CustomCode.SnakeBody(
this.bodyType, this.bodyType,
this.mesh,
{ {
x : this.position.x, x : this.position.x,
y : this.position.y y : this.position.y
@ -151,8 +152,7 @@ GameLib.CustomCode.SnakeBody.prototype.clone = function() {
{ {
x : this.direction.x, x : this.direction.x,
y : this.direction.y y : this.direction.y
}, }
this.mesh
); );
} }