Update: CC - Snake FS - Entity Loaded (21g30t1e75.js) 478 bytes modified
parent
9842a2799a
commit
500a20721e
|
@ -220,22 +220,49 @@ 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;
|
|
||||||
}
|
switch (orientation) {
|
||||||
|
case GameLib.CustomCode.ORIENTATION_UP :
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_DOWN) {
|
if ((this.position.y + 1) > GameLib.CustomCode.GRID_HEIGHT) {
|
||||||
this.position.y -= 1;
|
crash = true;
|
||||||
}
|
} else {
|
||||||
|
this.position.y += 1;
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_LEFT) {
|
}
|
||||||
this.position.x -= 1;
|
break;
|
||||||
}
|
case GameLib.CustomCode.ORIENTATION_DOWN :
|
||||||
|
if ((this.position.y - 1) < 0) {
|
||||||
if (orientation === GameLib.CustomCode.ORIENTATION_RIGHT) {
|
crash = true;
|
||||||
this.position.x += 1;
|
} 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 (!crash) {
|
||||||
|
console.log('check against body');
|
||||||
|
} else {
|
||||||
|
console.log('crashed!');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
|
||||||
this.flip = flip;
|
this.flip = flip;
|
||||||
|
|
Loading…
Reference in New Issue