1. ## 3 Ball Billiard

l have been looking for days to find some code to help me with a 3 Ball Billiard project , and the few l found
are for snooker or 15 ball billiards and the code is too complicated for me to adapt . Any ideas please ?

2. ## Re: 3 Ball Billiard

We need an idea on what exactly you need help with, like detecting ball to ball or side collisions, angular deflections, velocity and slowdown friction, game logic for scoring.

What have you coded so far?

3. ## Re: 3 Ball Billiard

Like l said , l have been looking for days for anything understandable to my limited experience , code to adapt , simple tutorials for all the above
you mentioned to make the 3 ball billiard , which to my mind is much easier and simpler that the 15 ball and holes game but there is nothing to
work with .

l have tried on a game l found , limited the balls (shapes) to 3 , changed shapes with balls(images) and it works somehow , but the balls collide
and reflect only when hit in the middle which is unrealistic .

In a 3 ball billiard (say , Red White and Yellow) the idea is to hit the other 2 balls with the White cueBall . If you fail , then the Yellow ball becomes
the cueBall and the player takes his turn .

4. ## Re: 3 Ball Billiard

Well, there is always going to be some math involved that you probably need to understand.
I would do a search using the phrase "billiard ball collision algorithm", and try to read a few of them, and watch the videos.

At its simplest (ignoring spinning effects, etc), the motion of the balls will come down to some simple concepts, but looking at the bare math behind it may seem harder to grasp.

Essentially, as for motion, when the two balls collide, the resulting motion of the two balls (assuming you didn't hit it straight on), will move apart at 90 degrees from each other.
For instance, you can track the position of the moving ball, and compare the distance of the center of that ball with the center of a ball that it is approaching. When the distance between the two centers equals the diameter of the ball, that is the point of contact.
The ball that is hit, will move off in the direction that is aligned with the line segment that is from the center of the moving ball, to the center of the hit ball.
And the ball that was moving will move along a line that is perpendicular (90 degrees) to that line segment.

Part of the trick in the calculation is determining how much momentum is transferred from the moving ball to the static ball, so you know what the resulting speed of each ball is as they continue to move.

Of course, if you have two moving balls hit each other, then it gets more complicated, as each ball has momentum to transfer, and each would be transferring that momentum along that same line segment between the two centers, but in opposite directions so you have an overall loss of momentum in that case.

Whether someone has already written an easy to use library for these collisions that you can understand, I don't know.
Since this is a general "Visual Basic" game forum, this forum applies to both legacy VB and VB.Net. Are you looking for VB6 code?

Since this is more specifically a Game demos forum (where you should be posting game demos), it doesn't seem like the correct forum for a question. It seems like it should have been asked one level up

5. ## Re: 3 Ball Billiard

First of all we are talking about VB6 .

Very nicely outlined theory , and of course l should know better as a supposed good straight 3 ball billiard , and 3 cushions player
in real life , but this is far from getting that knowledge in V6 code .

Unfortunately , there is not much around , that is , code which one could manipulate and adapt it to one's requirements .

The nearest l could find were snooker or 15 ball games .

https://www.planet-source-code.com/v...+bill&lngWId=1

This one , out of which l made the attached executable , by playing with the code , as you can see , there is no collision if the
cueBall does not hit the center of the other ball , and as such is of no use to me . However bouncing on all 4 sides of the table
is no bad . One plus , for me , is that l could change the shapes with images .

The other one "Billiardo Train"

https://www.planet-source-code.com/v...teria=billiard

Seems to be more realistic . You can hit the ball outside the center and the reflection is real enough . If you omit the rest of the
balls (shapes) and leave the cueBall and two other balls and increase their diameter , the effect is obvious . The problem with
this one is that l was not able to change the shapes with images .

l have noticed though , that most of the code in both , is related to the balls getting into the pockets , which for my project is useless .

The problem , if it is a problem for someone with you expertise , is how to overcome the switching of the cueBall .

l am sorry l posted in the wrong forum , but l suppose if it was a problem the Mods would move it .

6. ## Re: 3 Ball Billiard

Originally Posted by vbgeobas
...
l am sorry l posted in the wrong forum , but l suppose if it was a problem the Mods would move it ...
And "they" have.

Perhaps I'll have a chance to look at some stuff this weekend, pretty busy now. But I do have a number of things to get done this weekend as well, so I may not be of much help here. I would have sworn that there would have been some VB6 threads on the forum already dealing with some of these collision calculations in VB6. Jacob Roman, in particular comes to mine.

The issue is probably that the good ones aren't simple and the simple ones aren't good. And you won't usually find the code you want. You have to take code you find, understand how some parts of the code work that do part of what you need, and move those to a new project to start testing and building, not quite from scratch, but assembling from scratch.

7. ## Re: 3 Ball Billiard

We also have a problem with attaching compiled code, which is not allowed. The reason for that is entertaining, but also about 15 years old. Somebody added something to a program that was more than a little bad. Since we can't say anything about compiled code, we don't allow it.

You can attach source files and projects, as long as compiled code has been removed.

8. ## Re: 3 Ball Billiard

Sorry about that , l've no idea ....

10. ## Re: 3 Ball Billiard

You must be joking Mikle . This is far out of my league .
Fantastic , extraordinary project . l don't think there is anything around in VB6 , not even close .

However if and when l finish my 2D , 3 balls , French billiard project(still trying) , l will try to read it and see , if l can , how you achieved
that kind of presentation .

Thank you anyway .

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Featured