A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: boomerang bullets anyone?

  1. #1
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714

    boomerang bullets anyone?

    hi...
    can anyone out there add to this code so i can make a boomerang
    ...ive already got bullets working on the SPACEBAR release and would like to change this to a boomerang effect...heres the bullet code...
    onClipEvent (load) {
    shooting = false;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.SPACE) and !shooting) {
    gotoAndStop(2);
    shooting = true;
    shotdi = _root.hero._xscale/5;
    }
    if (_x<0 or _x>350) {
    shooting = false;
    }
    if (!shooting) {
    _x = _root.hero._x;
    _y = _root.hero._y-24;//height of bullet
    gotoAndStop(1);
    } else {
    _x += shotdi;
    }
    }
    thanks in advance....
    Last edited by hum; 04-19-2004 at 01:12 PM.

  2. #2
    Member
    Join Date
    Mar 2000
    Location
    Atlanta
    Posts
    83
    If you are doing this in side view and you don't want an arc, you could just treat your boomerangs as if they are affected by "gravity" but based at the thrower. Once the force of the throw ran out it would return to the thrower.

  3. #3
    Optimist Prime StenFLASH's Avatar
    Join Date
    Mar 2004
    Location
    Canberra, Australia
    Posts
    252
    I haven't thought this through completely but you could try this:

    Initialise gravity to 0 in the (load) event then change:

    } else {
    _x += shotdi;
    }

    to

    } else {
    _x += shotdi - gravity;
    gravity++;
    }

    Worked when I tested it. Obviously you can then remove the bullet clip when it's _x has returned to the hero's _x again.

    This boomerang thing would make a nice change compared to the other Flash platformers I keep seeing. It'd be cool if you could only have one boomerang and you can only shoot after it's been returned to you

    To that end you could also go about adjusting the boomerang's _y position in an "easing" manner relative to the hero so the boomerang can get back to it's owner regardless of if he's climbed a ladder or whatever since he threw it (means he doesnt have to wait on the same height level to the boomerang from when he threw it).

  4. #4
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714

    boomerang effect

    whoah.....nearly!
    it worked at first Stenflash as soon as i tested movie but then once id moved the hero about the screen it seemed to go wrong.....heres the fla. if you fancy a look , with the adjustments made on the bullet code like you wrote.....first shot worked but whizzed back past the hero ...then after that it seemed to go wrong!
    Last edited by hum; 04-19-2004 at 01:12 PM.

  5. #5
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714

    heres the fla.

    whooops...forgot fla.
    press SPACE to shoot

  6. #6
    Optimist Prime StenFLASH's Avatar
    Join Date
    Mar 2004
    Location
    Canberra, Australia
    Posts
    252
    I knew I didn't put enough thought in it, heheh. I didn't reset the gravity variable after it's returned to the hero. A temporary fix for the problem is to ....

    if (_x<0 or _x>350) {
    shooting = false;
    gravity = 0; <---- add this line in.
    }

    The only problem is that the boomerang effect doesn't work when thep layer is facing and shooting to the left. I'll take a more indepth look and post what i've come up with in a little while.

  7. #7
    Optimist Prime StenFLASH's Avatar
    Join Date
    Mar 2004
    Location
    Canberra, Australia
    Posts
    252
    Fixed!

    I've adjusted it so it works basically like a boomerang. Once the projectile returns to the hero it disappears and is ready to be fired again. I fixed it so it works regardless of the direction you're facing. You can even shoot the boomerang and run into it to catch it instead of waiting for it to fully return You might want to change the bullet speed to 15 (to make the boomerang go out further) since I found it looks better that way and will probably be a more useful weapon that way. You make it go too fast though and you might end up with trouble during hit detection as the bullet might just skip past enemies in its _x increments.

    All you've got left to do now, if you take one of my above suggestions, is to adjust the boomerangs _y coordinates as the player jumps so it follows the player and looks like it's properly caught (if it comes back while he's in mid air as opposed to it currently staying on it's horizontal line).

    One other thing is, at the moment you're not able to shoot the boomerang while moving (for reasons of the if statement that hides the boomerang). This is partly because of the method you've chosen to do your bullet. I personally would've done it by duplicating or attaching mc's.

    Oh btw, nice engine so far
    Attached Files Attached Files
    Last edited by StenFLASH; 04-13-2004 at 11:13 AM.

  8. #8
    Senior Member hum's Avatar
    Join Date
    Sep 2003
    Location
    CloudCuckooland
    Posts
    1,714

    boomerangtastic!!!

    nice one stenflash....
    hey do you remember spotting that bug in a recent platformer i made with the floating ninja stars?well anyway...i fixed that bug now ...i think i might just have to slow down the speed of them a little as feedback suggests that its impossible to get past them without damage!!take a look....oh and cheers for the help..
    http://www.davehum.com/gamedemo.htm
    Last edited by hum; 04-19-2004 at 01:12 PM.

  9. #9
    Optimist Prime StenFLASH's Avatar
    Join Date
    Mar 2004
    Location
    Canberra, Australia
    Posts
    252
    No worries I'm happy to help! Good to hear you fixed the ninja-star pause bug and yeah, it's very hard to get past unscathed, heheh.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center