Quote:
Originally Posted by khortez
[PHP]
this.equip = !this.equip;
|
You're toggling this.equip every time the fire button is pressed. You should only set this.equip to false whenever you want to unequip the weapon, and only set it to true when you want to equip the weapon.
if you want the fire button to also equip a gun the first time it's pressed, then do something like:
PHP Code:
// whenever the fire button is pressed
if (! this.equip) { // the gun isn't equipped yet, so equip it
this.equip = true;
// equip ganis or whatever else you want to do
return; // don't do any of the shooting stuff yet
}
// do shooting stuff
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.