I honestly have no idea where to begin with coding this. I want to be able to move something at the same speed, no matter what angle. No matter if it’s 45* or 23*. Any help?
I don’t quite understand. Velocity should be constant regardless of direction. If you’re looking to break the x and y components out to see how much to displace something based on a velocity, just multiply by sin and cosine, like so:
dx = velocity * cos(angle)
dy = velocity * sin(angle)
Keep in mind angles are usually in radians, not degrees. OpenGL being the exception when using the fixed function pipeline.
Well, the reason it might not make sense is because i’ve been using slope to move around the character.
If you already have a dx and dy and want to change the speed you can do this
double speed = Math.sqrt(dx*dx + dy*dy);
dx = dx / speed * newSpeed;
dy = dy / speed * newSpeed;