Quote:
Originally Posted by salesman
I should probably also add that you might want to use a timeout and keydown() functions instead of onKeyPressed() so that you can handle automatic weapons more efficiently.
|
Better yet:
PHP Code:
function GraalControl.onKeyDown(code, key) {
if (key == "d" && player.weapon == this && ! this.d) {
this.onTimeOut();
this.d = true;
}
}
function onTimeOut() {
if (player.weapon != this) {
return;
}
// shoot stuff goes here
if (this.isAutomatic) {
this.setTimer(this.sleepTime);
}
}
function GraalControl.onKeyUp(code, key) {
if (key == "d" && player.weapon == this) {
this.setTimer(0);
this.d = false;
}
}