Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: idiotbox on Fri 01/07/2005 03:31:41

Title: Machine guns?
Post by: idiotbox on Fri 01/07/2005 03:31:41
I've been fooling around with ways to get my players sub machine gun to fire with left mouse click until you release the left mouse button. He still only ends up shooting once. I've tried timers and using mouse.IsButtonPressed but he still only fires once. Anyone perhaps know a good code for it?
Title: Re: Machine guns?
Post by: monkey0506 on Fri 01/07/2005 04:18:59
maybe you could run it inside of rep_ex (repeatedly_execute):

function repeatedly_execute() {
  /* stuff */
  if (/* player has machine gun */) {
    if (mouse.IsButtonPressed(eMouseLeft)) {
      /* shoot */
    else {
      /* stop shooting */
      }
    }
  else {
    /* can't shoot -- doesn't have machine gun */
    }
  }


As you can see that's a lot of pseudo-code, but if you read over it you should be able to get the gist of what it does.  And just FYI, is the game running a blocking command during all of this?  If it is you'll have to change the code around some, for one thing maybe moving it into rep_ex_always so it runs during blocking commands.