Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 1545 bytes modified
parent
af97520e3f
commit
4853591f23
|
@ -68,7 +68,8 @@ this.advanceTime = 0;
|
||||||
* @type {{direction: {x: number, y: number}, orientation: number}}
|
* @type {{direction: {x: number, y: number}, orientation: number}}
|
||||||
*/
|
*/
|
||||||
this.state = {
|
this.state = {
|
||||||
orientation : 0
|
orientation : 0,
|
||||||
|
turning : false
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.CustomCode.prototype.createMaterial = function(image) {
|
GameLib.CustomCode.prototype.createMaterial = function(image) {
|
||||||
|
@ -125,6 +126,7 @@ this.meshPatty = this.createGameMesh(this.imagePatty);
|
||||||
* @param mesh
|
* @param mesh
|
||||||
* @param position
|
* @param position
|
||||||
* @param orientation
|
* @param orientation
|
||||||
|
* @param bodyType
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.CustomCode.SnakeBody = function(
|
GameLib.CustomCode.SnakeBody = function(
|
||||||
|
@ -155,8 +157,9 @@ GameLib.CustomCode.SnakeBody = function(
|
||||||
if (GameLib.Utils.UndefinedOrNull(bodyType)) {
|
if (GameLib.Utils.UndefinedOrNull(bodyType)) {
|
||||||
bodyType = GameLib.CustomCode.BODY_TYPE_NORMAL;
|
bodyType = GameLib.CustomCode.BODY_TYPE_NORMAL;
|
||||||
}
|
}
|
||||||
this.orientation = orientation;
|
this.bodyType = bodyType;
|
||||||
|
|
||||||
|
this.backupMesh = null;
|
||||||
|
|
||||||
this.applyToMesh();
|
this.applyToMesh();
|
||||||
};
|
};
|
||||||
|
@ -209,7 +212,8 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
var backup = {
|
var backup = {
|
||||||
x : 0,
|
x : 0,
|
||||||
y : 0,
|
y : 0,
|
||||||
orientation : GameLib.CustomCode.ORIENTATION_UP
|
orientation : GameLib.CustomCode.ORIENTATION_UP,
|
||||||
|
bodyType : GameLib.CustomCode.BODY_TYPE_NORMAL
|
||||||
};
|
};
|
||||||
|
|
||||||
this.snake.map(
|
this.snake.map(
|
||||||
|
@ -220,6 +224,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
backup.x = body.position.x;
|
backup.x = body.position.x;
|
||||||
backup.y = body.position.y;
|
backup.y = body.position.y;
|
||||||
backup.orientation = body.orientation;
|
backup.orientation = body.orientation;
|
||||||
|
backup.bodyType = body.bodyType;
|
||||||
|
|
||||||
body.advance(
|
body.advance(
|
||||||
this.state.orientation
|
this.state.orientation
|
||||||
|
@ -227,19 +232,54 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
if (
|
||||||
|
index === 1 &&
|
||||||
|
this.state.turning &&
|
||||||
|
body.bodyType !== GameLib.CustomCode.BODY_TYPE_TAIL
|
||||||
|
) {
|
||||||
|
|
||||||
|
body.backupMesh = body.mesh;
|
||||||
|
|
||||||
|
body.mesh = this.meshBreadCorner.clone();
|
||||||
|
|
||||||
|
body.bodyType = GameLib.CustomCode.BODY_TYPE_CORNER;
|
||||||
|
|
||||||
|
this.state.turning = false;
|
||||||
|
}
|
||||||
|
|
||||||
var temp = {
|
var temp = {
|
||||||
x : body.position.x,
|
x : body.position.x,
|
||||||
y : body.position.y,
|
y : body.position.y,
|
||||||
orientation : body.orientation
|
orientation : body.orientation,
|
||||||
|
bodyType : body.bodyType
|
||||||
};
|
};
|
||||||
|
|
||||||
body.position.x = backup.x;
|
body.position.x = backup.x;
|
||||||
body.position.y = backup.y;
|
body.position.y = backup.y;
|
||||||
body.orientation = backup.orientation;
|
body.orientation = backup.orientation;
|
||||||
|
body.bodyType = backup.bodyType;
|
||||||
|
|
||||||
backup.x = temp.x;
|
backup.x = temp.x;
|
||||||
backup.y = temp.y;
|
backup.y = temp.y;
|
||||||
backup.orientation = temp.orientation;
|
backup.orientation = temp.orientation;
|
||||||
|
backup.bodyType = temp.bodyType
|
||||||
|
|
||||||
|
if (
|
||||||
|
index === (this.snake.length - 1) &&
|
||||||
|
body.bodyType === GameLib.CustomCode.BODY_TYPE_CORNER
|
||||||
|
) {
|
||||||
|
// body.bodyType = GameLib.CustomCode.BODY_TYPE_TAIL;
|
||||||
|
//
|
||||||
|
// body.mesh.geometry = null;
|
||||||
|
//
|
||||||
|
// body.mesh.materials = null;
|
||||||
|
//
|
||||||
|
// body.mesh.remove();
|
||||||
|
//
|
||||||
|
// body.mesh = body.backupMesh;
|
||||||
|
//
|
||||||
|
// body.backupMesh = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body.applyToMesh();
|
body.applyToMesh();
|
||||||
|
@ -319,7 +359,8 @@ GameLib.Event.Subscribe(
|
||||||
x : 4,
|
x : 4,
|
||||||
y : 1
|
y : 1
|
||||||
},
|
},
|
||||||
0
|
0,
|
||||||
|
GameLib.CustomCode.BODY_TYPE_TAIL
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue