• 12
• 12
• 9
• 10
• 13

# shooting a basketball arc, Pixel-based

This topic is 3696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Anyone know how to simulate the arc of a basketball while shooting? I'm using 16.16 fixed point. The ball when shot or moving has a vX and vY variable that is added to its x any y coordinate. The basket is at some point (b.x, b.y). Anyone know how to find the proper vX and vY amounts? This is pixel based so Moving the object by (1<<16) will move it one pixel. -Thanks for any and all help.:)

##### Share on other sites
This is where some simple physics will help.

Take the initial velocity and find the vertical and horizontal components. Then use the formula vf=vi+at where "a" is -9.8 and t is how many seconds have passed since launch/throw.

Forgot the negative.

##### Share on other sites
I already know how to create the arc. I guess my question is how do I determine the correct xVel so that the ball ALWAYS hits the rim?

##### Share on other sites
You need to tell some more about the physics you are using. The vX and vY are not constants or you would not be able to get an arc. So what do the vX and vY depend on? How are they calculated?
Then people can try to derive an equation and solve it.

##### Share on other sites
OK, but I'm using pseudo physics.

 if(ball.shot){    ball.vX = someValue;    ball.vY = anotherValue; // anotherValue is negative since the positive y-axis points down}ball.x += ball.vX;ball.vY += GRAVITY; // In this case, GRAVITY is positive to drag the ball downball.y += ball.vY;if(objCol(&ball, &rim)){    ...    //take appropriate action here    ...}