User Tag List

Results 1 to 5 of 5

Thread: small balls falling into a horseshoe (help!)

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    small balls falling into a horseshoe (help!)

    Hey everyone... I've been working all day trying to get this reaction to work right, and I can't pull it off.

    I have a horseshoe (like a letter U) and I'm trying to drop balls into the opening and have them collect within the open space. Filling up gradually as they pile up.

    I can't manage to make it work right. I need the balls to bounce slightly, and gradually settle in, but they need to react to each other as well.

    I'm using the pin-ball movement for the balls falling in... they bounce off of each other but always begin to overlap and push outside of the horseshoe on the sides.

    If anyone is willing to have a look and point me in the right direction, I would really be thankful! The file is available via the following link:

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=130626&#Post130 626


  2. #2
    No Products Registered

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

    Re: small balls falling into a horseshoe (help!)

    Well first of all, I'm going to tell you what I tell everyone else: don't ever try to do ANYTHING out of the ordinary with the built in movements.

    What you're going to need to do is have 2 alterable values for each object, an xVel, and a yVel (velocity components).

    When 2 balls collide, they will hit off of each other as if they were hitting a plane tangent to both circles. So the formula for the new angle is: old angle - 2*normalline.

    To get the angle, you'll do the arctangent operation on the slope (y/x), and if the y value is negative, then you'll need to add 180 to that. The normal line will be 90+ angle between the balls. old angle is the angle the ball was travelling.

    To detect a collision, just use the built in is overlapping methods.

    One other thing, after a collision, I recommend you multiply each velocity component by .9 or something, so that they will lose energy and eventually come to a stop.

    Let me know if that needs any more explaining.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: small balls falling into a horseshoe (help!)

    Thanks LazyCoder...

    I follow multiplying the velocity down to nothing and I follow using the overlapping methods.

    So I suppose I need to store the angle in an alterable value... in fact, I am not sure I'm fully grasping this...

    can you clarify a bit more?

    Thanks!

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: small balls falling into a horseshoe (help!)

    Yeah, I still haven't made any progress here... if anyone has any info on pulling this off, please chime in! Thanks!

  5. #5
    No Products Registered

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

    Re: small balls falling into a horseshoe (help!)

    You get the angle by using the 2 different vector components xVel and yVel. You divide yVel by xVel, do the arctangent of that, and add 180 if yVel < 0.

    xVel and yVel are just vector components. For example, a vector at 30 degrees from the horizontal with a magnitude (speed in this case) of 4, then your xVel would be 3.464 (4Cos30) and you yVel would be 2 (4Sin30). This is consistent with the pythagorean formula in that 2^2 + 3.464^2 = 4^2

    The reason you break it up into components like that is that it makes it easier to move the balls because all you have to do then is just say Ball X = Ball X + xVel.

    To simulate gravity, keep adding a certain amount to yVel (you'll have to tinker with that for a while until you get a nice value).

    If you want to take this a step farther, you could store the positions in the alterable values as well, that way the positions would be decimal numbers, instead of integers (so the balls motion would be a bit smoother, and less error-prone).

    To take THAT a step farther, what you could also do is check if a ball is moving faster than it's radius, in which case it would probably be a good idea to move it a little bit at a time, check, then move it a little more, otherwise, if a ball gets going too fast, it might pass right through another one.

Similar Threads

  1. Three Balls then explode.
    By OldGuy in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 10th November 2017, 01:41 PM
  2. Go go balls! game
    By foyzul2002 in forum Android Released Games & Apps
    Replies: 3
    Last Post: 15th May 2013, 10:41 PM
  3. Reworking of Vector Balls Example
    By AyreGuitar in forum iOS Specific Example Files
    Replies: 5
    Last Post: 24th July 2011, 04:54 PM
  4. tutor,balls keep coming
    By mojoz in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 14th April 2011, 05:19 AM
  5. Help with boincing balls
    By LB in forum File Archive
    Replies: 2
    Last Post: 19th July 2010, 09:25 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
  •