View Single Post
  #7  
Old 09-08-2010, 03:53 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by salesman View Post
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(codekey) {
  if (
key == "d" && player.weapon == this && ! this.d) {
    
this.onTimeOut();
    
this.true;
  }
}

function 
onTimeOut() {
  if (
player.weapon != this) {
    return;
  }
  
  
// shoot stuff goes here
  
  
if (this.isAutomatic) {
    
this.setTimer(this.sleepTime);
  }
}

function 
GraalControl.onKeyUp(codekey) {
  if (
key == "d" && player.weapon == this) {
    
this.setTimer(0);
    
this.false;
  }

__________________
Reply With Quote