[SOLVED] Using Vectors to Control Movement
I am trying to create a program that accepts an angle and a speed from the user and then shoots a ball at that angle and at that speed, slowing down as it goes. I have a program that does close to that, but my current method is not accurate at all. The movement of the ball is determined by my "slope calculator". This is a separate class that creates a triangle from the ball's X position, Y position, and launch angle. It then finds the slope of the hypotenuse and moves the ball up and over accordingly. After a certain number of loops, the values are decremented, causing the ball to slow down and eventually stop. This is not realistic at all, however, and adding more balls to the table would be incredibly difficult.
My programming teacher told me to use vectors instead. By using vectors, I could create a vector representing friction to slow the ball down, and I could also add other balls to the screen to have them interact. This would be done through vector addition. He said vectors would make the program more accurate and more versatile.
MY PROBLEM: I have no idea how to implement vectors in my code. Is there a Java class that is specifically made for vectors? Is there perhaps another way to approach this problem?
Any help is greatly appreciated.