User Tag List

Page 2 of 2 FirstFirst 1 2
Results 11 to 14 of 14

Thread: Expression for rebounding bullet

  1. #11
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression for rebounding bullet

    Its not an easy effect. If you use a 360 degree bullet movement, the problem is that you don't know the angle of the wall. Unless you're playing on a field that has vertex-style walls, you ca't simply "retrieve the angle" of the wall.

    For my current 360 degree platformer project that you can see here:
    http://create-games.com/project.asp?view=main&id=1617
    I have created an interesting algorithm for finding the angle of walls on a 2d pixel map, in a fairly efficient and reliable manner. Unfortunately, its a very complicated procedure compared to what you might be used to, and you really have to understand it to implement it.

    Once you've actually got the angle of a wall, its easy to do a reflection over a line in vector math- its just a reflection over a line. Its getting the angle that is tougher.

    Heres an example file:
    http://sites.google.com/site/claniraq/stuff/Collision.gam?attredirects=0&d=1

    It basically operates like this: When the object collides with a backdrop, you check the angle of the object, and cast out two "detectors" at lets say 8 pixels away at a perpendicular angle to the object's movement, one to the left, one to the right. So if this was an object going straight down, you'd have one 8 pixels left, one 8 pixels right. For each of these detectors, you check if its overlapping a backdrop at this position or not- if its not, you rotate it 'upwards' until it is no longer overlapping a backdrop. If it *was*, you rotate it 'downwards' until it overlaps a backdrop- then undo the lastmost rotate (add 1 degree).

    From the two points it has determined now, you've got the surface of the object mapped, and just finding the angle between these two detectors gives you the surface angle of the object, which you can then use to reflect. Virtually my entire platformer game is powered by this angle detection, using it from everything from monster AI to move around curvy surfaces, to player movement, to projectiles, etc

  2. #12
    No Products Registered

    Join Date
    Oct 2008
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression for rebounding bullet

    I understand so far, but once I have the slant of the wall from the two detectors, how do I make the path of the bullet reflect over that line?

    also, I am only using a few tiles (so only a few slopes) wouldn't this render the use of the detectors useless, because the slopes won't change, I'll just make different conditions for each slope. Or am I missing something?

  3. #13
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression for rebounding bullet

    yeah if you know the angle of each collision then you can skip the whole detectors bit. That code is only useful for having "any shape" objects in your game.

    The formula for reflection over a line is something like:

    Angle3 = 2 * Angle1 - ((Angle2 + 180) mod 360)

    Angle1 = angle of the surface
    Angle2 = angle your object is travelling
    Angle3 = angle of reflection

    You might have to adjust by 90 degrees some direction, thats just copy/pasted right out of that example file I posted.

  4. #14
    No Products Registered

    Join Date
    Oct 2008
    Posts
    76
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Expression for rebounding bullet

    Perfect, I'll mess around with this for a bit. Thank you so much.

Page 2 of 2 FirstFirst 1 2

Similar Threads

  1. Bullet Widget
    By MuddyMole in forum Widgets
    Replies: 16
    Last Post: 22nd August 2018, 11:02 AM
  2. Bullet-Time: There is no Foo!
    By Dines in forum Articles
    Replies: 24
    Last Post: 2nd June 2013, 10:04 PM
  3. If bullet overlaps a certain object, damage the shooter of the bullet
    By StardustSpeedman in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 10th September 2012, 02:43 PM
  4. Bullet spray
    By Exploder1010 in forum File Archive
    Replies: 8
    Last Post: 4th August 2011, 05:59 AM
  5. bullet holes.
    By piki in forum Multimedia Fusion 2 - Technical Support
    Replies: 19
    Last Post: 8th October 2007, 03:43 PM

Posting Permissions

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