Thread: Trajectory
View Single Post
  #4 (permalink)  
Old 10-12-2008, 10:20 PM
JDCAce's Avatar
JDCAce JDCAce is offline
Member
 
Join Date: Oct 2008
Location: Columbus, GA, US
Posts: 29
JDCAce is on a distinguished road
Send a message via AIM to JDCAce Send a message via MSN to JDCAce Send a message via Yahoo to JDCAce Send a message via Skype™ to JDCAce
Of course I don't expect someone to code it for me. What I meant to ask is a "head start" or sorts. Right now, I'm not sure where to begin. I can't even think of an algorithm to help tackle this problem.

I have one idea, but I don't know if it would work. Obtain the trajectory of the ball (the imaginary line the ball is traveling) by storing the x- and y-positions, then have the ball move forward one step and obtain the new position. This gives me the "entry line." I then "draw" and imaginary horizontal line out from the paddle at whatever y-position the ball hit it. I then calculate the angle of the first line to the second line; this is the angle of impact. To have the ball bounce off the paddle at the correct angle, I "draw" a new imaginary line from the paddle relative to the entry line with an angle of two times this angle of impact. Then I send the ball moving along that "line."

That is the only thing I can come up with, and, although it sounds like it might work, I have no idea to go about coding it. Retrieving the angle of impact sounds doable, but I have no clue how to send the ball moving along a set line.

Just a nudge in the right direction (no pun intended) would help.
__________________
"Things are made of littler things that jiggle."
Reply With Quote