Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 478 bytes modified
parent
9842a2799a
commit
500a20721e
|
@ -220,21 +220,48 @@ GameLib.CustomCode.SnakeBody.prototype.applyToMesh = function() {
|
||||||
|
|
||||||
GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation, flip) {
|
GameLib.CustomCode.SnakeBody.prototype.advance = function(orientation, flip) {
|
||||||
|
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_UP) {
|
var crash = false;
|
||||||
this.position.y += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
switch (orientation) {
|
||||||
this.position.y -= 1;
|
case GameLib.CustomCode.ORIENTATION_UP :
|
||||||
}
|
if ((this.position.y + 1) > GameLib.CustomCode.GRID_HEIGHT) {
|
||||||
|
crash = true;
|
||||||
|
} else {
|
||||||
|
this.position.y += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GameLib.CustomCode.ORIENTATION_DOWN :
|
||||||
|
if ((this.position.y - 1) < 0) {
|
||||||
|
crash = true;
|
||||||
|
} else {
|
||||||
|
this.position.y -= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GameLib.CustomCode.ORIENTATION_LEFT :
|
||||||
|
if ((this.position.x - 1) < 0) {
|
||||||
|
crash = true;
|
||||||
|
} else {
|
||||||
|
this.position.x -= 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GameLib.CustomCode.ORIENTATION_RIGHT :
|
||||||
|
if ((this.position.x + 1) > GameLib.CustomCode.GRID_WIDTH) {
|
||||||
|
crash = true;
|
||||||
|
} else {
|
||||||
|
this.position.x += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
console.warn('unknown orientation');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
if (!crash) {
|
||||||
this.position.x -= 1;
|
console.log('check against body');
|
||||||
}
|
} else {
|
||||||
|
console.log('crashed!');
|
||||||
|
}
|
||||||
|
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
|
||||||
this.position.x += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue