Objects Following Mouse
in
Programming Questions
•
10 months ago
Hi, I'm trying to make an AsteroidsESK type game. I haven't started coding it yet but I'm trying to figure out how to get objects to follow the mouse. Right now I know of two ways, setting the X and Y coordinates of the object to the mouse and limiting the X and Y values and the second method is "easing". Finding the difference between the two points and dividing them. The problem with the first method is that the objects can only move in 8 directions, UP, DOWN, LEFT, RIGHT and the diagonals and the problem with the second method is that the objects change velocity depending on the distance. Does anyone know how to get the objects to float directly towards the mouse at a constant rate?
I've been looking for some code that does what I'm looking for like this one but I'm so bad at reading and understanding other peoples code.
http://www.openprocessing.org/sketch/34499
The ellipse created here float directly to the mouse at a constant rate.
The same issue applies for the bullets that player will be shooting but if I can get one to work, I can get the other.
I've been looking for some code that does what I'm looking for like this one but I'm so bad at reading and understanding other peoples code.
http://www.openprocessing.org/sketch/34499
The ellipse created here float directly to the mouse at a constant rate.
The same issue applies for the bullets that player will be shooting but if I can get one to work, I can get the other.
1