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