Machine guns?

Started by idiotbox, Fri 01/07/2005 03:31:41

Previous topic - Next topic

idiotbox

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?

monkey0506

maybe you could run it inside of rep_ex (repeatedly_execute):

Code: ags
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.

SMF spam blocked by CleanTalk