PDA

Click to See Complete Forum and Search --> : Bouncing Balls


SteveCRM
Aug 7th, 1999, 03:47 AM
I can make a ball bounce around the screen, but how would i make it bounce of of objects, such as other images?

Thanx

Steve

------------------

Darkwraith
Jul 17th, 2003, 07:30 PM
NOTE: This is only for X direction:

(Image1.left + width) <= Image2.left for a right collision
(Image1.left) <= (Image2.left + width) for a left collision

Its basically the same in the Y direction.

SLH
Jul 18th, 2003, 03:01 AM
I think i have a project that might help.... i'll see if i can fish it out...

SLH
Jul 18th, 2003, 03:05 AM
Found it - it's by no means perfect, but it should give you a start.

Add a form with some shapes on it called shape (index them).

I also experimented with curves, but that was never finished so i commented it out.

Have to attach the file - too long to post.

Darkwraith
Jul 18th, 2003, 08:55 AM
if you are trying to do circular collision regions, then

Center(Image1)^2 + Center(Image2)^2 >= (Image1.Radius + Image2.Radius)^2

would define a collision. Center() would give you the X or Y coordinate of the center of the object.

Sorry this is all in pseudocode but it should be enough. :)

SLH
Jul 20th, 2003, 06:42 PM
Originally posted by Darkwraith
if you are trying to do circular collision regions...


No, i can do that fine (see attached), it was getting the ball to bounce realistically off the surfaces of convex and concave curves that was the hard part. I just couldn't get my head around the mathmatics of it all.

Thanks for the help though. :)

SLH
Jul 20th, 2003, 06:45 PM
DOh, forgot to attach the file - and i cant edit the previous post to include it either, ah well, here it is.

SteveCRM
Jul 20th, 2003, 06:54 PM
damn guys....this is from 1999! :eek: I haven't used vb in over 2-3 years :p

SLH
Jul 20th, 2003, 07:09 PM
LOL :o

At least i wasn't the one to resurrect it. :D

Electroman
Jul 20th, 2003, 07:13 PM
Darkwraith strikes again, thats two in about 2-3days you've brought threads back from the past, I think I'll have a go at it soon:D:D.

The other one (http://www.vbforums.com/showthread.php?s=&threadid=15601):D

Darkwraith
Jul 20th, 2003, 09:05 PM
:D

But now we have a thread on collision regions. :)