Update: CC - Snake FS - Key Up (306204wy29.js) 104 bytes modified
parent
e596b1a02a
commit
f70ecbd2db
|
@ -3,54 +3,56 @@ if (!this.entityLoaded) {
|
|||
}
|
||||
|
||||
if (!this.initialized) {
|
||||
this.direction = this.entityLoaded.direction;
|
||||
|
||||
this.state = this.entityLoaded.state;
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
||||
if (data.keyCode === GameLib.System.Input.KEY_UP) {
|
||||
if (this.direction.y === -1) {
|
||||
if (this.state.direction.y === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.direction.y === 1) {
|
||||
if (this.state.direction.y === 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.direction.x === 1) {
|
||||
this.direction.y = 1;
|
||||
this.rotation += Math.PI / 2;
|
||||
if (this.state.direction.x === 1) {
|
||||
this.state.direction.y = 1;
|
||||
this.state.rotation += Math.PI / 2;
|
||||
}
|
||||
|
||||
if (this.direction.x === -1) {
|
||||
this.direction.y = 1;
|
||||
this.rotation -= Math.PI / 2;
|
||||
if (this.state.direction.x === -1) {
|
||||
this.state.direction.y = 1;
|
||||
this.state.rotation -= Math.PI / 2;
|
||||
}
|
||||
|
||||
this.direction.x = 0;
|
||||
this.state.direction.x = 0;
|
||||
}
|
||||
|
||||
if (data.keyCode === GameLib.System.Input.KEY_DOWN) {
|
||||
if (this.direction.y === 1) {
|
||||
if (this.state.direction.y === 1) {
|
||||
return;
|
||||
}
|
||||
this.direction.y = -1;
|
||||
this.direction.x = 0;
|
||||
this.state.direction.y = -1;
|
||||
this.state.direction.x = 0;
|
||||
}
|
||||
|
||||
if (data.keyCode === GameLib.System.Input.KEY_LEFT) {
|
||||
if (this.direction.x === 1) {
|
||||
if (this.state.direction.x === 1) {
|
||||
return;
|
||||
}
|
||||
this.direction.y = 0;
|
||||
this.direction.x = -1;
|
||||
this.state.direction.y = 0;
|
||||
this.state.direction.x = -1;
|
||||
}
|
||||
|
||||
if (data.keyCode === GameLib.System.Input.KEY_RIGHT) {
|
||||
if (this.direction.x === -1) {
|
||||
if (this.state.direction.x === -1) {
|
||||
return;
|
||||
}
|
||||
this.direction.y = 0;
|
||||
this.direction.x = 1;
|
||||
this.state.direction.y = 0;
|
||||
this.state.direction.x = 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue