Hello, I have a players position on the screen as x and y.
I’m using this to figure out the difference:
Mouse.getX() - x;
Mouse.getY() - y;
Then putting the value into this to get the angle the player moves towards.
Math.atan2(y, x);
Now that I have an angle to work with, I use this to move the player in the direction of that angle.
speedx += 3*(Math.cos(playerAngle));
speedy += 3*(Math.sin(playerAngle));
So, now I have something like this:
nPKLETHLbmI
I’m trying to find out how I can check if the players x,y position
has reached the radius of a circle that is in the center of the screen.
So, as if the ship was on a leash, which has its origin at the center of the screen.
(unrelated)
I’ve tried a bunch of guess work. I’m currently doing A level math just haven’t covered this stuff yet.
My idea is that I can use the value of the radius to slow down the ship the closer it gets to the edge. But I’m sure I can work that out if I solve this.
Anyone know how it can be done?
Thanks