I've been working for the past few weeks on a very basic billiards game that requires collision detection. While I can "bounce" off the sides of the table just fine, I'm having real trouble getting two balls to "see" one another and collide. I can't quite grasp how it should be done w/o some sort of brute force method where each ball checks to see if it currently colliding with every other ball.
This way seems inefficient and requires a lot of work... plus I can never seem to figure out WHERE I should actually be detecting the collision (should the game sort of work this out, or should balls be responsible for their own collision detection?).
At this stage, I don't need it to be very realistic, I just want it to work. Has anyone worked out a similar problem before (or seen code that does something similar in Smalltalk/Squeak)? Is there any advice anyone can give me?
Thanks.
I too am trying to learn my way around Squeak, especially the etoy environment. I found a terrific section in Mark Guzdial's Squeak book about creating an ellipse that simulates gravity as it falls. I added a variation by having my ellipse bounce off of an object when it lands on it. My ellipse is yellow and the object that it strikes is light blue. What you see below is the script that checks to see when the 2 colors meet. When that happens (and only then) is another script (kick) activated.
squeakland@lists.squeakfoundation.org