6 Replies Latest reply on Sep 10, 2007 6:48 PM by kglad

    Shooting a bullet.

    Donjworks Level 1

      I am making this game. For the dude to shoot I use this code (it is applied to a movie clip that covers the Background:


      onClipEvent (mouseDown) {
      endX = _root._xmouse;
      endY = _root._ymouse;
      startX = _root.b1._x
      startY = _root.b1._y
      onClipEvent (enterFrame) {
      speed = 10;
      _root.b1._x = _root.dude._x
      _root.b1._y = _root.dude._y
      _root.b1._x = _root.b1._x + (endX-startX)/speed
      _root.b1._y = _root.b1._y + (endY-startY)/speed


      'b1' is the bullet
      'dude' is where it shoots from
      startX/Y is where the bullet starts
      endX/Y is where the person clicks, and the direction of the bullet, not unnecessarily where I want the bullet to go.

      The problem is the closer I click to the dude when I shoot, the slower the bullet goes, how can I make this a fixed speed??

      Thanks, sorry if this is rather confusing, or I left some important info out, If you have any questions just ask...


      -Donald J