Update: CC - Snake FS - Key Up (306204wy29.js) 178 bytes modified

beta.r3js.org
-=yb4f310 2018-03-13 13:21:18 +01:00
parent 939d35628c
commit 814fde174e
1 changed files with 12 additions and 0 deletions

View File

@ -8,21 +8,33 @@ if (!this.initialized) {
} }
if (data.keyCode === GameLib.System.Input.KEY_UP) { if (data.keyCode === GameLib.System.Input.KEY_UP) {
if (this.direction.y === -1) {
return;
}
this.direction.y = 1; this.direction.y = 1;
this.direction.x = 0; this.direction.x = 0;
} }
if (data.keyCode === GameLib.System.Input.KEY_DOWN) { if (data.keyCode === GameLib.System.Input.KEY_DOWN) {
if (this.direction.y === 1) {
return;
}
this.direction.y = -1; this.direction.y = -1;
this.direction.x = 0; this.direction.x = 0;
} }
if (data.keyCode === GameLib.System.Input.KEY_LEFT) { if (data.keyCode === GameLib.System.Input.KEY_LEFT) {
if (this.direction.x === 1) {
return;
}
this.direction.y = 0; this.direction.y = 0;
this.direction.x = -1; this.direction.x = -1;
} }
if (data.keyCode === GameLib.System.Input.KEY_RIGHT) { if (data.keyCode === GameLib.System.Input.KEY_RIGHT) {
if (this.direction.x === -1) {
return;
}
this.direction.y = 0; this.direction.y = 0;
this.direction.x = 1; this.direction.x = 1;
} }