Test, Try my PoolGame?
Hello,
I''ve written a pool game which uses OpenGL and DX8.1. I''d be interested in any feedback from users!
My website:
www.alwayslearn.com
Thanks!
Nice work!
How did you handle the reaction of the balls when they hit each other? I actually have a similar problem!
How did you handle the reaction of the balls when they hit each other? I actually have a similar problem!
Its called physics
Before you program a physiscs engine here are some physics concepts you should know:
Momentum
Energy
Elastic and Inelastic collisions
Friction
I think there are more. Depends on how realistic you wan't to make your game.....
You can look this up in almost any physics book.
[edited by - snisarenko on October 27, 2002 12:44:38 PM]
Before you program a physiscs engine here are some physics concepts you should know:
Momentum
Energy
Elastic and Inelastic collisions
Friction
I think there are more. Depends on how realistic you wan't to make your game.....
You can look this up in almost any physics book.
[edited by - snisarenko on October 27, 2002 12:44:38 PM]
quote:
Original post by glnefugio
Nice work!
Thanks!

quote:
How did you handle the reaction of the balls when they hit each other? I actually have a similar problem!
As snisarenko said, I used basic Newtonian mechanics. The conservation of linear momentum and vector math for the collisions. I also used rotational mechanics for the ball rolling.
I wasn''t able to easily handle multiple simultaneous collisions, however, so I cheated a bit. :D
If you''re dealing with spheres, you''ll find these easiest for collision detection and reaction.
Hope this helps. If not, then let me know.
It runs must better on a machine with a good frame rate. I like the crack of the hard shots, very satisfying 
I haven't made a billiard game myself, but I'm assuming the algorithm will go like this (it might help with simultaneous collisions, I don't know, I haven't proven it out)
1. Detect the earliest collision in a single frame (if two happen at the same time, just pick one)
2. Move all billiards up to that point in time
3. Reassign direction of colliding objects (they shouldn't be heading towards each other anymore)
4. Go back to 1., detecting the next earliest collision, or else consume the rest of the frame time moving the billiards
If there is a simultaneous collision, then the other collision should be detected immediately on the next iteration. In a mass collision, all the collisions and reassignments of velocities shouldn't ever cause an infinite loop (especially since there is deceleration and open space around the balls so they will be knocked away)
[edited by - Waverider on October 27, 2002 9:31:45 PM]

I haven't made a billiard game myself, but I'm assuming the algorithm will go like this (it might help with simultaneous collisions, I don't know, I haven't proven it out)
1. Detect the earliest collision in a single frame (if two happen at the same time, just pick one)
2. Move all billiards up to that point in time
3. Reassign direction of colliding objects (they shouldn't be heading towards each other anymore)
4. Go back to 1., detecting the next earliest collision, or else consume the rest of the frame time moving the billiards
If there is a simultaneous collision, then the other collision should be detected immediately on the next iteration. In a mass collision, all the collisions and reassignments of velocities shouldn't ever cause an infinite loop (especially since there is deceleration and open space around the balls so they will be knocked away)
[edited by - Waverider on October 27, 2002 9:31:45 PM]
It's not what you're taught, it's what you learn.
Oh come on, how stupid do you think I''am Huh??? I know that Physiks is in there!!
My question is the how do you calculate the Angles after the Balls hit?? I know where they hit and when they hit and all that stuff I only wanna know how to calulate the angle with that they leave!
My question is the how do you calculate the Angles after the Balls hit?? I know where they hit and when they hit and all that stuff I only wanna know how to calulate the angle with that they leave!
He said he couldn''t easily handle simultaneous collisions. I was suggesting an algorithm that I would use that I think may solve the problem.
As for calculating the new angles after impact, that''s for research. I don''t know that calculation myself.
As for calculating the new angles after impact, that''s for research. I don''t know that calculation myself.
It's not what you're taught, it's what you learn.
quote:
Original post by glnefugio
My question is the how do you calculate the Angles after the Balls hit?? I know where they hit and when they hit and all that stuff I only wanna know how to calulate the angle with that they leave!
Okay, here's the gist of it. Each ball has a velocity vector. Upon collision, I break the velocity vector of the first ball into two components. One that goes through the center of the 2nd ball and one that is at right angles to the ray through the center.
The component that goes through the center of the 2nd ball is transferred to the other ball, while the perpendicular component remains with the first ball.
I perform the same steps for the 2nd ball with respect to the first ball.
So, in a nutshell, each ball exchanges velocities along the line of collision, but retains the velocities which are perpendicular to the collision. You add the two resultant components for each ball, and, voila, you have a new velocity vector for each ball.
I can do it this way because I assume that the mass of each ball is equal. If the masses were different the component directions would be the same, but the way that the energy transfered would be different. That is, the proportions would be different.
I hope that's clear.
[edited by - John Alway on October 28, 2002 11:30:41 AM]
quote:
Original post by Waverider
It runs must better on a machine with a good frame rate. I like the crack of the hard shots, very satisfying
Hey, if you don''t mind, can you tell me your frame rate and your basic machine specs? And anyone else who is interested!

quote:
If there is a simultaneous collision, then the other collision should be detected immediately on the next iteration. In a mass collision, all the collisions and reassignments of velocities shouldn''t ever cause an infinite loop (especially since there is deceleration and open space around the balls so they will be knocked away)
Not a bad idea, Waverider. I might rethink the way I''m doing it. I do have 16 balls, which is C(16,2) potential colliders, C being all of he possible collisions of the 16 balls taken two at a time, which amounts to 120.
My home machine specs are:
CPU: XP 1800
Video: GeForce 3 Ti 500
Memory: 512MB RAM
FPS: 60
My other machine:
CPU: P3 800
Video: NVidia TNT2
Memory: 256MB RAM
FPS: ~20 (fluctuates badly - my video driver is messed up on this machine)
[edited by - Waverider on October 28, 2002 10:55:00 PM]
CPU: XP 1800
Video: GeForce 3 Ti 500
Memory: 512MB RAM
FPS: 60
My other machine:
CPU: P3 800
Video: NVidia TNT2
Memory: 256MB RAM
FPS: ~20 (fluctuates badly - my video driver is messed up on this machine)
[edited by - Waverider on October 28, 2002 10:55:00 PM]
It's not what you're taught, it's what you learn.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement