User Tag List

Results 1 to 4 of 4

Thread: Accurate Angles

  1. #1
    No Products Registered

    Join Date
    Dec 2006
    Posts
    1,332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Accurate Angles

    I am working on something in which you draw a line and then watch the ball interact with the line. I have a working gravity engine and the bounce works alright, but I am looking for a way to make more accurate horizontal movement. The system I am using right now for horizontal movement moves the same distance every bounce of the ball. I am looking for a way to make the ball bounce according to the angle or slope of the area it lands on. I have an example of what I have so far. Press the space bar to start the ball motion.

    http://putstuff.putfile.com/76865/9381026

  2. #2
    No Products Registered

    Join Date
    Jul 2006
    Location
    Texas
    Posts
    1,225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Accurate Angles

    Well first of all you need to find the angle that the ball is traveling when it hits an obstacle. You can do that by storing it's coordinates before every move so you can have a record of where it was the previous frame. Then you just get the angle between those two points (I use the clickteam movement controller object for that). Since it's a ball, this makes finding the collision angle so much easier. What you do is you loop through all the edge pixels of the ball and see which ones are obstacles, then you average it up to get the normal line angle. Then you use this formula to calculate the new angle (I think it goes something like): normal line angle + (normal line angle - current angle)
    Then you have to find the speed at which it is travelling by taking the distance between it's previous frame point, and it's current point (you can use the clickteam movement controller for this also). Then using the new angle you calcualted, you can then set the x and y velocities using this formula:
    xVel = (sin(newangle)*speed)
    yVel = (cos(newangle)*speed)

  3. #3
    No Products Registered

    Join Date
    Dec 2006
    Posts
    1,332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Accurate Angles

    Thanks thats really helpful!

  4. #4
    No Products Registered

    Join Date
    Jul 2006
    Location
    Texas
    Posts
    1,225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Accurate Angles

    No problem. :grin:

Similar Threads

  1. Position not accurate with cos
    By mobichan in forum Android Export Module Version 2.0
    Replies: 0
    Last Post: 1st May 2013, 04:21 AM
  2. Replies: 4
    Last Post: 2nd July 2012, 08:05 PM
  3. more accurate collision
    By malospam in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 21st September 2011, 03:08 AM
  4. Accurate jump
    By stAtrill in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 4th May 2007, 12:46 AM
  5. Accurate paralaxing
    By stuckboy in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 17th July 2006, 03:27 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
  •