r3-custom-code/306204wy29.js

61 lines
1.1 KiB
JavaScript
Raw Normal View History

if (!this.entityLoaded) {
return;
}
if (!this.initialized) {
this.state = this.entityLoaded.state;
this.initialized = true;
}
if (data.keyCode === GameLib.System.Input.KEY_UP) {
if (this.state.direction.y === -1) {
return;
}
if (this.state.direction.y === 1) {
return;
}
if (this.state.direction.x === 1) {
this.state.direction.y = 1;
this.state.rotation += Math.PI / 2;
}
if (this.state.direction.x === -1) {
this.state.direction.y = 1;
this.state.rotation -= Math.PI / 2;
}
this.state.direction.x = 0;
}
if (data.keyCode === GameLib.System.Input.KEY_DOWN) {
if (this.state.direction.y === 1) {
return;
}
this.state.direction.y = -1;
this.state.direction.x = 0;
}
if (data.keyCode === GameLib.System.Input.KEY_LEFT) {
if (this.state.direction.x === 1) {
return;
}
this.state.direction.y = 0;
this.state.direction.x = -1;
}
if (data.keyCode === GameLib.System.Input.KEY_RIGHT) {
if (this.state.direction.x === -1) {
return;
}
this.state.direction.y = 0;
this.state.direction.x = 1;
}
console.log(data);
//@ sourceURL=keyUp.js