User Tag List

Results 1 to 10 of 10

Thread: 360 Degree Bounce

  1. #1
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    geothefaust's Avatar
    Join Date
    Jul 2006
    Location
    Portland, OR
    Posts
    498
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    360 Degree Bounce

    Hi all,


    I'm creating a custom movement engine, and am having a hard time trying to code the bounce section of it. I've searched the forums already but have found limited resources (Probably due to the forum change-over. As I recall there were a lot of examples before said change-over.). Could any one point me to some examples of custom bouncing? Thanks!

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    How about you search the old forums?

  3. #3
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    geothefaust's Avatar
    Join Date
    Jul 2006
    Location
    Portland, OR
    Posts
    498
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks! Good to know those are still around. I poke around a bit, but, I found more information in one of your posts. This here:

    Code:
    "Player" is overlapping "Obstacle"
    Repeat while "W" is pressed
    Subtract Sin(Angle("Player")+90)*3 from Alterable Value X
    Subtract Sin(Angle("Player")+90)*3 from Alterable Value Y
    From Post:
    http://community.clickteam.com/showthread.php?t=71308&p=530106&viewfull=1#post530 106

    That was very helpful and what I recall using in the past. So thanks! But now the question is, say the player object is rotated in one direction and moving in another. How would you calculate the difference here so that the player would still bounce properly?

    I'm sure it's right under my nose, and am probably making it more complicated then it needs to be. Heh.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would only ever use the movement angle, which should be equal to atan2(-Yspeed,Xspeed)

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I don't know, actually. The other thing was actually just a copied version of the code the person asking the question used to move forwards, only I used subtraction instead of addition.

  6. #6
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    geothefaust's Avatar
    Join Date
    Jul 2006
    Location
    Portland, OR
    Posts
    498
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jacob View Post
    You would only ever use the movement angle, which should be equal to atan2(-Yspeed,Xspeed)
    Thanks Jacob! That returns a usable value. I'm only having to find out where to use it at now. Thoughts on that?


    Quote Originally Posted by happygreenfrog View Post
    I don't know, actually. The other thing was actually just a copied version of the code the person asking the question used to move forwards, only I used subtraction instead of addition.
    No worries, thanks anyway.

  7. #7
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'd use that as your object's movement angle in an equation that gets you the reflecting angle, which was said by Looki in a post a few days ago:

    Quote Originally Posted by Looki View Post
    The general formula to reflect an angle is (2*Plane - Angle). Angle is the angle you're going at, Plane is obviously the plane's angle. That should do it. The Y axis has an angle of 0, the X axis an angle of 90.
    EDIT: Although if you're setting a value or something other than the actual angle of the object, you'll have to account for angle wrapping, so this formula should take care of it: ((2*Plane+360-Angle) mod 360)

  8. #8
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    In order to have a proper reflection you need to know the normal angle of the surface that is being struck- very easy in a vertex-point 3d engine, but in a sprite-based 2d engine, there is no such thing.
    If you're using flat surfaces that are just up and down and left and right, all at 90 degree angles, there are simpler tricks- just come up with a way to find if you're hitting a vertical or horizontal plane, and reflect accordingly. But if you're using smooth surfaces and curves and other angles, you'll need something like the algorithm I talk about in this article;
    http://community.clickteam.com/showthread.php?t=60695

  9. #9
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    geothefaust's Avatar
    Join Date
    Jul 2006
    Location
    Portland, OR
    Posts
    498
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Hi guys, thanks for the responses! I really appreciate it.

    Quote Originally Posted by Jacob View Post
    You'd use that as your object's movement angle in an equation that gets you the reflecting angle, which was said by Looki in a post a few days ago:

    EDIT: Although if you're setting a value or something other than the actual angle of the object, you'll have to account for angle wrapping, so this formula should take care of it: ((2*Plane+360-Angle) mod 360)
    Thanks Jacob! This really helped out, the only problem I'm seeing now is that sometimes the player controlled object will continue moving to then fully penetrate the surface area it should be bouncing off of. I've put together a test scene to work in, any chance you could look at it? Here is the URL:

    https://www.dropbox.com/s/7792qiqo3w...tion%200.2.mfa


    Quote Originally Posted by Pixelthief View Post
    In order to have a proper reflection you need to know the normal angle of the surface that is being struck- very easy in a vertex-point 3d engine, but in a sprite-based 2d engine, there is no such thing.
    If you're using flat surfaces that are just up and down and left and right, all at 90 degree angles, there are simpler tricks- just come up with a way to find if you're hitting a vertical or horizontal plane, and reflect accordingly. But if you're using smooth surfaces and curves and other angles, you'll need something like the algorithm I talk about in this article;
    http://community.clickteam.com/showthread.php?t=60695
    Wow this looks really interesting! I'm more of an artist then a programmer, so I might have some trouble implementing it. How would one go about using this in a MMF way with out using the LAU script? On a similar note, you mention it is easier in 3D... And you are so right. If this were a 3D engine I could simply get the vertex indices and get a normal, of just grab a poly and use the normal from there. Anyway, it's interesting to see how it is done in this regard. I would love to further understand it. Is there by chance an example file that one could explore? Thanks!

  10. #10
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't studied his algorithm, but basically you can make two actives at 1px with the hotspot set to the radius of the object you're bouncing, then you can use a fastloop to spin them around in opposite directions until they hit an obstacle. The angle between them will be the angle of the plane, and the normal angle will be plane+90.

    EDIT: Are you planning on having angled and curved surfaces to bounce off of? If you only have 45 and 90 degree turns, you can find out which sides of the objects are touching the wall (and therefore know what the angle of the wall is) and simply reverse the X or Y position. If the top or bottom collide, reverse Y. If the left or right collide, reverse X.

Similar Threads

  1. 360 degree shooting
    By Hayo in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 24th March 2010, 02:49 PM
  2. 360 degree shooting
    By Triclyde in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 10th March 2010, 07:13 AM
  3. 360 degree movement
    By Farflame in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 10th May 2009, 05:19 PM
  4. 360 degree aim
    By SamG in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 19th October 2008, 05:08 PM
  5. 360 degree movement
    By Dynamite in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 26th March 2008, 10:11 AM

Posting Permissions

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