Pool(Billiards) physics (Need help)
Pool(Billiards) physics (Need help)
Hello everyone, I'm a beginner game developer, trying to make my first game. My idea is based on billiards physics, but I don't have a clue how to make it. Can I get any suggestions on what I should study or any library that could help me with that?
Re: Pool(Billiards) physics (Need help)
Well, it depends on the degree of sophistication you're after.
If you just want basic bounces, without considering aspects like friction with the cushions or during ball collisions, or whether the ball is hit off-centre to give it a spinning efect, then you could do with a simple bouncing-based scheme which only requires a bit of vector math and very little trigonometry, if any.
If you are after an accurate simulation of effects, frictions during impacts, etc. then you're better off studying dynamics in detail, because there's a lot involved there.
The middle compromise is probably to use the love.physics module, which will not give you a very accurate simulation, but it will be able to include bouncing, cushion friction and (2D) rotational momentum without you worrying about implementing them yourself.
If you just want basic bounces, without considering aspects like friction with the cushions or during ball collisions, or whether the ball is hit off-centre to give it a spinning efect, then you could do with a simple bouncing-based scheme which only requires a bit of vector math and very little trigonometry, if any.
If you are after an accurate simulation of effects, frictions during impacts, etc. then you're better off studying dynamics in detail, because there's a lot involved there.
The middle compromise is probably to use the love.physics module, which will not give you a very accurate simulation, but it will be able to include bouncing, cushion friction and (2D) rotational momentum without you worrying about implementing them yourself.
Re: Pool(Billiards) physics (Need help)
Just use the love.physics module while setting gravitation to 0. That should work.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Pool(Billiards) physics (Need help)
Here's a PoC of the love.physics approach. Lots of magic numbers everywhere as I fine-tuned the parameters by trial-and-error, sorry.
As I feared, love.physics doesn't do bouncing too well, and balls sometimes stick to the cushions if they are very slow, even when setting restitution to 1.
As I feared, love.physics doesn't do bouncing too well, and balls sometimes stick to the cushions if they are very slow, even when setting restitution to 1.
- Attachments
-
- lovePhysicsPool.love
- (1.49 KiB) Downloaded 191 times
- BrotSagtMist
- Party member
- Posts: 657
- Joined: Fri Aug 06, 2021 10:30 pm
Re: Pool(Billiards) physics (Need help)
This is already cooler than 90% of what you find in comercial pool games for old consoles.
The problem here is that this kind of game is all about physics, you gotta have to nail it or else its garbage.
So pool is not the smartest starting point to get into game dev.
The problem here is that this kind of game is all about physics, you gotta have to nail it or else its garbage.
So pool is not the smartest starting point to get into game dev.
obey
Re: Pool(Billiards) physics (Need help)
Anything with complex physics is not suitable as a beginner's project. Although having libraries (or API such love.physics), to make it easier, helps.BrotSagtMist wrote: ↑Mon May 20, 2024 6:44 pm This is already cooler than 90% of what you find in comercial pool games for old consoles.
The problem here is that this kind of game is all about physics, you gotta have to nail it or else its garbage.
So pool is not the smartest starting point to get into game dev.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Pool(Billiards) physics (Need help)
Thanks all, that helped me a lot!
Re: Pool(Billiards) physics (Need help)
I've made small example with circles collision detection and static/dynamic resolving: viewtopic.php?p=240339#p240339
Two main collision functions:
Two main collision functions:
Code: Select all
function pushback (collision)
local particles = collision.particles
local b1, b2 = particles[1], particles[2]
local overlap = collision.overlap
local nx, ny = collision.nx, collision.ny
b1.x = b1.x - nx*overlap
b2.x = b2.x + nx*overlap
b1.y = b1.y - ny*overlap
b2.y = b2.y + ny*overlap
end
Code: Select all
function rollback (collision)
local particles = collision.particles
local b1, b2 = particles[1], particles[2]
local nx, ny = collision.nx, collision.ny -- normal
local tx, ty = -ny, nx -- tangent
local dptan1 = b1.vx*tx + b1.vy*ty
local dptan2 = b2.vx*tx + b2.vy*ty
local dpnorm1 = b1.vx*nx + b1.vy*ny
local dpnorm2 = b2.vx*nx + b2.vy*ny
local m1 = (dpnorm1*(b1.mass-b2.mass)+2*b2.mass*dpnorm2)/(b1.mass+b2.mass)
local m2 = (dpnorm2*(b2.mass-b1.mass)+2*b1.mass*dpnorm1)/(b1.mass+b2.mass)
b1.vx = tx*dptan1 + nx*m1
b1.vy = ty*dptan1 + ny*m1
b2.vx = tx*dptan2 + nx*m2
b2.vy = ty*dptan2 + ny*m2
end
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests