User Tag List

Results 1 to 10 of 10

Thread: get angle of custom-made ball movement

  1. #1
    No Products Registered

    Join Date
    Sep 2006
    Location
    Greece
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get angle of custom-made ball movement

    hi all.

    I have a custom bouncing ball movement, the usual sort, Xspeed Yspeed --> setX Pos to X+Xspeed, etc.

    it works wonders with bouncing and all that, but I haven't been able to find a way to get the angle (or direction) the ball is headed.

    I tried Atan (Yspeed/Xspeed) and it returns useless numbers. Shouldn't it return the angle corresponding to tan(yspeed/xspeed) or am I being completely stupid?

    Any ideas?

  2. #2
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    Sounds somewhat wrong to me. If yspeed=6, and xspeed=2, 6 / 2 = 3. If the values is negative, -6 / -2 = 3. So obviously, yspeed/xspeed does not by itself provide information which can be used to find out the full direction.

    To be honest, I don't know the solution though, sorry. I'll see if I can figure it out.

  3. #3
    No Products Registered

    Join Date
    Sep 2006
    Location
    Greece
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    you're right :/ I could check for the angle between two points, but I can't think of any points that would be useful...

    thanks for giving it a try though. it's bugging me to no end

  4. #4
    No Products Registered

    Join Date
    Jun 2006
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    Theres an example here about making bouncing balls.

    http://clickteam.com/center/showflat.php/Cat/0/Number/16380/an/0/page/0#Post16380

    This formula has come up a lot in the past.

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    edit: I have already figured out a solution to this a few posts bellow.

    It's the opposite she wants though. This example converts an angle into movement, with the formula:

    x = x + (cos(Angle)*speed)
    y = y + (sin(Angle)*speed)

    Christina has obviously already set up a working engine, probably using the other method which I prefer. It doesn't involve angles.

    X Pos = X Pos + X Speed
    Y Pos = Y Pos + Y Speed

    Based on the x speed any y speed variables, how do you calculate what direction the object is actually facing? I think that is the problem here, and there is certainly a way to do it, without reprogramming the engine into the less flexible one that the example demonstrates.

    Just consider it. To add gravity to the example engine, you have to modify the direction and speed. To add gravity to Christina's engine, you only have to increase the Y speed.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    I am comming close to a solution that might work fine... I hope.

  7. #7
    No Products Registered

    Join Date
    Jul 2006
    Location
    Umeå, Sweden
    Posts
    1,090
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    Sqr( (X + X Speed) pow 2 + (Y + Y Speed) pow 2 ) / 11.25

    should to the trick <img src="/center/images/graemlins/wink.gif" alt="" />

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS Export Module
    Nifflas's Avatar
    Join Date
    Jul 2006
    Posts
    2,613
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    Christina: Here's my solution. I suddenly remembered a formula that finds out the angle from one point to another. I realized it can easily be modified to works with speeds instead. Move the object with the arrow keys, and it will always point toward where it's heading. It is based around the "new xpos=xpos+xspeed, new ypos=ypos+yspeed" engine that I think you use.

    Daniel Nordigic: Can you explain how your formula figures out the angle? It looks more like a distance calculation, than a direction calculation.

  9. #9
    No Products Registered

    Join Date
    Sep 2006
    Location
    Greece
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    ah excellent!
    Thanks everyone for putting your brains through this strain! Such a great forum..

    Clicktastic&gt; Thank you! as Nifflas said, I have already settled on a slightly better custom ball movement, otherwise your solutions looks good too.

    Daniel&gt; I'd love to know how this formula works and what it does too!

    Nifflas&gt; Thank you so much! It is exactly the formula I use for movement, and now you've given me the formula I need for the angle.

    I did try the Sine(SpeedY/hypotenuse) after you found fault in my Tangent logic (you were right of course). But even then, I couldn't get the number to look like an Angle and got disappointed. The modifications you did, really do the trick! It's a great piece of math, thank you again!

    I promise to show you all my little 3D-looking ball trick soon.

    kisses
    christina

  10. #10
    No Products Registered

    Join Date
    Jul 2006
    Location
    Umeå, Sweden
    Posts
    1,090
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: get angle of custom-made ball movement

    Opps... that's exactly what it does xD
    my misstake..Must have had some sort of error or something...

Similar Threads

  1. Custom Bouncing Ball Movement Stopping Bug
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 24th August 2013, 08:56 PM
  2. Custom ball movement?
    By blub in forum Multimedia Fusion 2 - Technical Support
    Replies: 16
    Last Post: 13th June 2012, 02:27 PM
  3. Replies: 3
    Last Post: 24th March 2010, 02:03 AM
  4. Custom Ball Movement
    By izac in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 12th January 2008, 01:11 AM
  5. Slopes for custom made platform movement
    By Langol in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 26th September 2007, 05:53 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
  •