1 Reply Latest reply on Apr 22, 2006 7:57 AM by Newsgroup_User

    Moving sprite at random intervals

    merc_maniac
      Hi can anyone help please -
      I'm currently making a game for an assignment, and i want to make the sprites move from the left of the screen to the right, and appear at random time intervals. I am using the following code at the minute, but it is only making the sprite move back and forward across the stage, not go from left to right.

      global gvFlip, gnumberhits, gscore
      property pMySprite, pIncrement, pLeftBound, pRightBound

      on beginsprite me
      pMySprite = sprite(me.spritenum)
      pLeftBound = (-20)
      pRightBound = 640
      pIncrement = random (10)
      end

      on mouseup me
      puppetsound 3 "gunshot"
      end

      on exitframe me
      pMySprite.loch = pMySprite.loch + pIncrement
      if pMySprite.loch > pRightBound OR pMySprite.loch < pLeftBound then
      pIncrement = pIncrement * -1
      pMySprite.fliph = NOT pMySprite.fliph
      end if

      if gvFlip = true then
      pIncrement = pIncrement * -1
      pMySprite.fliph = NOT pMySprite.fliph
      gvFlip = false
      end if

      end

      If someone could point me in the right direction that would be great thanks.
      Tim