2D Physics (top down billiard game)

43 Views Asked by At

I'm designing a power system for a billiard type game and am struggling to figure out mathematically what I should do here. I'm pretty new to programming, but if I understand the logic I should probably be able to figure how to code this.

For ease of use, let's say I have a max power of 100, am shooting with max power, and am shooting up and to the right. I use a drag and let go to shoot mechanism. Consider the following scenarios:

Drag left (purely x-axis shot) - ball shoots to the right with 100% power
Drag down (purely y-axis shot) - ball shoots up with 100% power
Drag left-down (45 degree each axis) - what should happen?
Drag left-down so I aiming 70 degree up, 20 degrees right - what should happen?

3 & 4 I think would have the same logic, but using #3 as an example, I've tried the following:

Splitting the 100 power between each axis - the ball ends up moving a much shorter distance than a purely x or y axis shot.
Giving 100 power to each x and y-axis - this gives significantly more power to a diagonal shot.

I'm tracking the distance of each shot using and I can clearly see that the distance covered by a diagonal shot that is splitting the power is less than a pure-axis shot - ideally a pure axis shot and a diagonal shot cover the same distance as all I'm doing is shooting in a single direction, just like with a pure axis shot.

I've been fiddling around with this for too long, so I thought I would ask some help here.