Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 224 bytes modified
parent
f70ecbd2db
commit
3b06cb3f68
|
@ -53,11 +53,13 @@ this.snake = [];
|
|||
this.grid = [];
|
||||
this.speed = GameLib.CustomCode.SPEED_INITIAL;
|
||||
this.advanceTime = 0;
|
||||
this.direction = {
|
||||
x : -1,
|
||||
y : 0
|
||||
}
|
||||
this.rotation = Math.PI / 2;
|
||||
this.state = {
|
||||
direction : {
|
||||
x : -1,
|
||||
y : 0
|
||||
},
|
||||
rotation : Math.PI / 2
|
||||
};
|
||||
|
||||
GameLib.CustomCode.prototype.createMaterial = function(image) {
|
||||
var diffuseMap = new GameLib.D3.Texture.Image(
|
||||
|
@ -188,6 +190,7 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
}
|
||||
|
||||
var position = {x:0, y:0};
|
||||
var rotation = 0;
|
||||
|
||||
this.snake.map(
|
||||
function(body, index) {
|
||||
|
@ -197,7 +200,12 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
position.x = body.position.x;
|
||||
position.y = body.position.y;
|
||||
|
||||
body.advance(this.direction, this.rotation);
|
||||
rotation = body.rotation;
|
||||
|
||||
body.advance(
|
||||
this.state.direction,
|
||||
this.state.rotation
|
||||
);
|
||||
|
||||
} else {
|
||||
|
||||
|
@ -206,12 +214,18 @@ GameLib.CustomCode.prototype.advanceSnake = function(delta) {
|
|||
y : body.position.y
|
||||
};
|
||||
|
||||
var tempRotation = body.rotation;
|
||||
|
||||
body.position.x = position.x;
|
||||
body.position.y = position.y;
|
||||
|
||||
body.rotation = rotation;
|
||||
|
||||
position.x = tempPosition.x;
|
||||
position.y = tempPosition.y;
|
||||
|
||||
rotation = tempRotation;
|
||||
|
||||
}
|
||||
|
||||
body.applyToMesh();
|
||||
|
@ -256,11 +270,13 @@ GameLib.Event.Subscribe(
|
|||
}
|
||||
)
|
||||
|
||||
this.direction = {
|
||||
x : -1,
|
||||
y : 0
|
||||
}
|
||||
this.rotation = Math.PI / 2;
|
||||
this.state = {
|
||||
direction : {
|
||||
x : -1,
|
||||
y : 0
|
||||
},
|
||||
rotation : Math.PI / 2
|
||||
};
|
||||
|
||||
this.snake = [
|
||||
new GameLib.CustomCode.SnakeBody(
|
||||
|
|
Loading…
Reference in New Issue